feat(Bigbot): added docker-compose (#2538)

* chore: fix script extension

* chore: remove extention

* fix: at least it run can now

* chore: fix dev script

* refactor: change to use env file for config

* chore: update readme

* refactor: put dotenv to top

* feat: add docker and influxdb

* chore: disable deno fmt on bigbot node_modules

* style: deno fmt

* style: deno fmt after upgrade deno

* chore: remove dev console.log

* chore: reverse the influxdb env

* chore: limit the influxdb to localhost

* refactor: seperate build process

* chore: add user pass docs

* refactor: route all to handler

* fix: skip if webhook not exist

* fix: change to use runMethod for send response

* chore: gateway don't depend on bot

* fix: skip if webhook not exist

* fix: first command and error reply not sending

* fix: add try catch to error reply

* fix: reverse interactive.reply

* feat: add fetch analytics to bot process
This commit is contained in:
Jonathan Ho
2022-10-22 07:28:33 -05:00
committed by GitHub
parent b7688bc6b0
commit a8a89d4b16
26 changed files with 535 additions and 441 deletions
+7 -7
View File
@@ -1,7 +1,7 @@
---
sidebar_position: 5
---
# Same as discord.js [collection][def]
[def]: https://discord.js.org/#/docs/collection/main/class/Collection
---
sidebar_position: 5
---
# Same as discord.js [collection][def]
[def]: https://discord.js.org/#/docs/collection/main/class/Collection
+7 -7
View File
@@ -1,7 +1,7 @@
---
sidebar_position: 4
---
# Documentation [at][def]
[def]: https://deno.land/x/amethyst@v4.2.0/mod.ts?s=AmethystEmbed
---
sidebar_position: 4
---
# Documentation [at][def]
[def]: https://deno.land/x/amethyst@v4.2.0/mod.ts?s=AmethystEmbed
+1 -1
View File
@@ -1 +1 @@
{ "label": "Amethyst Framework", "position": 3 }
{ "label": "Amethyst Framework", "position": 3 }
+99 -97
View File
@@ -1,97 +1,99 @@
---
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)
---
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)
+70 -77
View File
@@ -1,77 +1,70 @@
---
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)
---
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)
+3 -3
View File
@@ -7,8 +7,8 @@ sidebar_position: 1
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.
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)
@@ -50,5 +50,5 @@ Deno: [link](https://deno.land/x/amethyst)
Npm:
```bash
npm i @thereallonewolf/amethystframework
npm i @thereallonewolf/amethystframework
```