mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
feat(Amethyst): Add a basic guide. (#2534)
* feat(Amethyst): Add a basic guide. * Fix formating
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
# Same as discord.js [collection][def]
|
||||
|
||||
[def]: https://discord.js.org/#/docs/collection/main/class/Collection
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Documentation [at][def]
|
||||
|
||||
[def]: https://deno.land/x/amethyst@v4.2.0/mod.ts?s=AmethystEmbed
|
||||
@@ -0,0 +1 @@
|
||||
{ "label": "Amethyst Framework", "position": 3 }
|
||||
@@ -0,0 +1,97 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Creating an client
|
||||
|
||||
Let's review each choice and what it does.
|
||||
|
||||
- `owners`, You may specify the proprietors of the bot using this. The inhibitors make use of this.
|
||||
- `prefix`, The string a user should use at the beginning of their message to identify it as a command to the bot. Only message commands can use this, and the parameter can be either a string or a function.
|
||||
- `botMentionAsPrefix`, Determines whether a user's mention of a bot qualifies as a prefix.
|
||||
- `ignoreBots`, Allow bots to execute commands.
|
||||
- `defaultCooldown`, Defualt cooldown for all commands.
|
||||
- `ignoreCooldown`, List of people who bypass cooldowns.
|
||||
- `commandDir`, Path to the command directory used by the fileloader.
|
||||
- `eventDir`, Path to the event directory used by the fileloader.
|
||||
- `inhibitorDir`, Path to the inhibitor directory used by the fileloader.
|
||||
- `prefixCaseSensitive`, Indicates whether or not the prefix is case-sensitive.
|
||||
- `extras`, Extras that are used by your client, such as a database instance or a music player.
|
||||
|
||||
## Client Extras
|
||||
|
||||
When using discord.js we often do stuff like `client.musicplayer=player;` and in order to maintain this ease Amethyst allows you to do `client.extras.musicplayer=player;`.
|
||||
|
||||
NOTE: Typing will not work on `client.extras`.
|
||||
|
||||
## Client Properties
|
||||
|
||||
```ts
|
||||
user: User;
|
||||
events: AmethystEvents;
|
||||
messageCollectors: AmethystCollection<string, MessageCollector>;
|
||||
componentCollectors: AmethystCollection<bigint, ComponentCollector>;
|
||||
reactionCollectors: AmethystCollection<bigint, ReactionCollector>;
|
||||
runningTasks: runningTasks;
|
||||
tasks: AmethystCollection<string, AmethystTask>;
|
||||
category: AmethystCollection<string, Category>;
|
||||
inhibitors: AmethystCollection<
|
||||
string,
|
||||
<T extends Command = Command>(
|
||||
bot: AmethystBot,
|
||||
command: T,
|
||||
options: { memberId?: bigint; channelId: bigint; guildId?: bigint }
|
||||
) => true | AmethystError
|
||||
>;
|
||||
owners?: bigint[];
|
||||
botMentionAsPrefix?: boolean;
|
||||
prefixCaseSensitive?: boolean;
|
||||
defaultCooldown?: CommandCooldown;
|
||||
ignoreCooldown?: bigint[];
|
||||
guildOnly?: boolean;
|
||||
messageQuotedArguments?: boolean;
|
||||
ignoreBots?: boolean;
|
||||
dmOnly?: boolean;
|
||||
eventHandler: AmethystEventHandler;
|
||||
extras: any;
|
||||
prefix?:
|
||||
| string
|
||||
| string[]
|
||||
| ((bot: AmethystBot, message: Message) => Async<string | string[]>);
|
||||
|
||||
on(name: string, callback: (...args: any) => unknown): void;
|
||||
once(name: string, callback: (...args: any) => unknown): void;
|
||||
|
||||
amethystUtils: {
|
||||
awaitComponent(
|
||||
messageId: bigint,
|
||||
options?: ComponentCollectorOptions & { maxUsage?: number }
|
||||
): Promise<Interaction[]>,
|
||||
awaitReaction(
|
||||
messageId: bigint,
|
||||
options?: ReactionCollectorOptions & { maxUsage?: number }
|
||||
): Promise<AmethystReaction[]>,
|
||||
awaitMessage(
|
||||
memberId: bigint,
|
||||
channelId: bigint,
|
||||
options?: MessageCollectorOptions & { maxUsage?: number }
|
||||
): Promise<Message[]>,
|
||||
createCommand(command: CommandOptions): void,
|
||||
createCategory(category: CategoryOptions): void,
|
||||
updateCategory(category: CategoryOptions): void,
|
||||
createTask(task: AmethystTask): void,
|
||||
clearTasks(): void,
|
||||
createInhibitor<T extends Command = Command>(
|
||||
name: string,
|
||||
inhibitor: (
|
||||
bot: AmethystBot,
|
||||
command: T,
|
||||
options?: { memberId?: bigint; guildId?: bigint; channelId: bigint }
|
||||
) => true | AmethystError
|
||||
): void,
|
||||
deleteInhibitor(name: string): void,
|
||||
updateSlashCommands(): void,
|
||||
}
|
||||
```
|
||||
|
||||
## [Documentation](https://deno.land/x/amethyst@v4.2.0/mod.ts?s=AmethystBotOptions)
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
# Lets Create a simple bot in Node.js
|
||||
|
||||
- **Step 1**: Create a typescript project with index.ts as main file.
|
||||
|
||||
- **Step 2**: Installing packages.
|
||||
Install following packages.
|
||||
|
||||
```bash
|
||||
npm i @thereallonewolf/amethystframework
|
||||
```
|
||||
|
||||
- **Step 3**: Create a index.ts file.
|
||||
|
||||
- **Step 4**: Add following code in index.ts file, replacing TOKEN with your bot token.
|
||||
|
||||
```ts
|
||||
import { ActivityTypes, Bot, createBot,GatewayIntents,startBot } from "discordeno";
|
||||
import { enableCachePlugin, enableCacheSweepers } from "discordeno/cache-plugin";
|
||||
import {
|
||||
AmethystBot,
|
||||
Context,
|
||||
enableAmethystPlugin,
|
||||
} from "@thereallonewolf/amethystframework";
|
||||
|
||||
|
||||
config();
|
||||
let baseClient = createBot({
|
||||
token: "TOKEN",
|
||||
intents: GatewayIntents.Guilds | GatewayIntents.GuildMessages | GatewayIntents.MessageContent,
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
let client = enableAmethystPlugin(enableCachePlugin(baseClient), {
|
||||
botMentionAsPrefix: true,
|
||||
prefix: "!",//Can be a function or a string.
|
||||
ignoreBots: false,
|
||||
});
|
||||
enableCacheSweepers(client);
|
||||
|
||||
|
||||
client.on("ready", () => {
|
||||
console.log("I am up and running");
|
||||
});
|
||||
|
||||
client.amethystUtils.createCategory({
|
||||
name: "general",
|
||||
description: "My general commands",
|
||||
uniqueCommands: true,
|
||||
default: "",
|
||||
});
|
||||
client.amethystUtils.createCommand({
|
||||
name: "ping",
|
||||
description: "Pong!",
|
||||
commandType: ["application", "message"],
|
||||
category: "general",
|
||||
args: [],
|
||||
async execute(bot: AmethystBot, ctx: Context) {
|
||||
ctx.reply({content:"Pong!"});
|
||||
},
|
||||
});
|
||||
|
||||
client.amethystUtils.updateSlashCommands();
|
||||
startBot(client);
|
||||
```
|
||||
|
||||
- **Step 5**: Invite your bot and compile index.ts and run it.
|
||||
Then you can use `/general ping` or `!ping`
|
||||
|
||||
- **Step 6**: Useful links:
|
||||
|
||||
1. Command Options can be found [here](https://github.com/AmethystFramework/framework/blob/master/src/types/commandOptions.ts).
|
||||
2. Category Options [here](https://github.com/AmethystFramework/framework/blob/master/src/types/categoryOptions.ts)
|
||||
3. Full [Documentation](https://deno.land/x/amethyst)
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Amethyst
|
||||
|
||||
Amethyst is a [Discordeno](https://github.com/discordeno/discordeno) plugin that is incredibly robust and flexible. It
|
||||
promotes standard practices and is geared at bigger bots.
|
||||
|
||||
This framework is not for you if you cannot utilise Maps and Sets without reading them up. We
|
||||
presume you have a solid foundation in typescript/javascript and dicord bots.
|
||||
|
||||
[Documentation](https://deno.land/x/amethyst)
|
||||
|
||||
## Features
|
||||
|
||||
- Thanks to Amethyst's adaptability, you can change a lot of things and add features as you see appropriate.
|
||||
- A developer may create slash or message interactions with Amethyst.
|
||||
- Assistance with interactions, such as selection, built-in buttons, and more.
|
||||
- Custom discord.js like event system without the event emitter.
|
||||
- Explore more incredible features of our framework.
|
||||
|
||||
## Why Amethyst?
|
||||
|
||||
Amethyst makes use of the [Discordeno](https://github.com/discordeno/discordeno) plugin system to streamline your coding
|
||||
process and help you get going more quickly. Support for message and slash commands that doesn't need altering any code.
|
||||
|
||||
- Fully programmable
|
||||
|
||||
- Easy to learn and utilise.
|
||||
|
||||
- Conversion from Discord.js bots is simple.
|
||||
|
||||
## Ideas
|
||||
|
||||
The objective is to provide a framework that can be used with both Node.js and Deno while minimising transitions and
|
||||
rewrites.
|
||||
|
||||
- Easy to understand and use.
|
||||
- Cover up complexity in the engine keeping the end user interface as simple as possible.
|
||||
|
||||
## Future Updates
|
||||
|
||||
Creation of discord setup wizards for commands like welcome, context menus and paginated messages.
|
||||
|
||||
## Installation
|
||||
|
||||
Deno: [link](https://deno.land/x/amethyst)
|
||||
|
||||
Npm:
|
||||
|
||||
```bash
|
||||
npm i @thereallonewolf/amethystframework
|
||||
```
|
||||
Reference in New Issue
Block a user