mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 08:50:07 +00:00
* 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
1.9 KiB
1.9 KiB
sidebar_position
| 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.
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.
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 pingor!ping -
Step 6: Useful links:
- Command Options can be found here.
- Category Options here
- Full Documentation