From 783da6077965168774f8c09ea7b62acda68cceb2 Mon Sep 17 00:00:00 2001 From: deepsarda <92147339+deepsarda@users.noreply.github.com> Date: Thu, 20 Oct 2022 07:02:39 +0530 Subject: [PATCH] feat(Amethyst): Add a basic guide. (#2534) * feat(Amethyst): Add a basic guide. * Fix formating --- site/docs/amethyst/AmethystCollection.md | 7 ++ site/docs/amethyst/AmethystEmbed.md | 7 ++ site/docs/amethyst/_category_.json | 1 + site/docs/amethyst/client.md | 97 ++++++++++++++++++++++++ site/docs/amethyst/exampleBot.md | 77 +++++++++++++++++++ site/docs/amethyst/intro.md | 54 +++++++++++++ 6 files changed, 243 insertions(+) create mode 100644 site/docs/amethyst/AmethystCollection.md create mode 100644 site/docs/amethyst/AmethystEmbed.md create mode 100644 site/docs/amethyst/_category_.json create mode 100644 site/docs/amethyst/client.md create mode 100644 site/docs/amethyst/exampleBot.md create mode 100644 site/docs/amethyst/intro.md diff --git a/site/docs/amethyst/AmethystCollection.md b/site/docs/amethyst/AmethystCollection.md new file mode 100644 index 000000000..59fd0ff76 --- /dev/null +++ b/site/docs/amethyst/AmethystCollection.md @@ -0,0 +1,7 @@ +--- +sidebar_position: 5 +--- + +# Same as discord.js [collection][def] + +[def]: https://discord.js.org/#/docs/collection/main/class/Collection diff --git a/site/docs/amethyst/AmethystEmbed.md b/site/docs/amethyst/AmethystEmbed.md new file mode 100644 index 000000000..45bfd6d36 --- /dev/null +++ b/site/docs/amethyst/AmethystEmbed.md @@ -0,0 +1,7 @@ +--- +sidebar_position: 4 +--- + +# Documentation [at][def] + +[def]: https://deno.land/x/amethyst@v4.2.0/mod.ts?s=AmethystEmbed diff --git a/site/docs/amethyst/_category_.json b/site/docs/amethyst/_category_.json new file mode 100644 index 000000000..05b2a8b40 --- /dev/null +++ b/site/docs/amethyst/_category_.json @@ -0,0 +1 @@ +{ "label": "Amethyst Framework", "position": 3 } diff --git a/site/docs/amethyst/client.md b/site/docs/amethyst/client.md new file mode 100644 index 000000000..39399f28d --- /dev/null +++ b/site/docs/amethyst/client.md @@ -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; + componentCollectors: AmethystCollection; + reactionCollectors: AmethystCollection; + runningTasks: runningTasks; + tasks: AmethystCollection; + category: AmethystCollection; + inhibitors: AmethystCollection< + string, + ( + 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); + + 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, + awaitReaction( + messageId: bigint, + options?: ReactionCollectorOptions & { maxUsage?: number } + ): Promise, + awaitMessage( + memberId: bigint, + channelId: bigint, + options?: MessageCollectorOptions & { maxUsage?: number } + ): Promise, + createCommand(command: CommandOptions): void, + createCategory(category: CategoryOptions): void, + updateCategory(category: CategoryOptions): void, + createTask(task: AmethystTask): void, + clearTasks(): void, + createInhibitor( + 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) diff --git a/site/docs/amethyst/exampleBot.md b/site/docs/amethyst/exampleBot.md new file mode 100644 index 000000000..758310b04 --- /dev/null +++ b/site/docs/amethyst/exampleBot.md @@ -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) diff --git a/site/docs/amethyst/intro.md b/site/docs/amethyst/intro.md new file mode 100644 index 000000000..f8b18e02e --- /dev/null +++ b/site/docs/amethyst/intro.md @@ -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 +```