Files
discordeno/site/docs/amethyst/exampleBot.md
Jonathan Ho 7a1a41fac8 CI: Run benchmark (#2563)
* fix(bench): try to fix benchmark

* style: deno fmt

* fix: remove check formating

* fix: add fake token

* fix: tranform

* deno fmt

* add parseFloat

* fix unit

* refactor: change fetch target to benchrepo

* fix: oldBot

* refactor: use custom input

* ci: add tee

* style: deno fmt

* ci: cache deps

* chore: remove

* ci: add memory benchmark

* fix: fix url for main repo

* deno fmt

* ci: add comment-always

* fix: link

* just trying trigger

* ci: only push on main

* fix: type

* fix: range

* fixed

* style: deno fmt

* fix: path

* Add upload output

* style: deno fmt

* ci: add create branch on pr owner's repo

* fix: github.repository

* ci: fix remove id benchmark-action

* fix

* fix: type

* reverse change

* ci: add cache

* feat: add using cache

* bench: update name and ignore previous when ci

* style: name

* feat: fix pr message style

* add more benchmark

* deno fmt

* fix

* fix: wording

* chore: only run on success

* fix: used last head as current commit
2022-10-29 14:22:23 -05:00

2.0 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 { createBot, GatewayIntents, startBot } from "discordeno";
import { enableCachePlugin, enableCacheSweepers } from "discordeno/cache-plugin";
import {
  AmethystBot,
  Category,
  Command,
  Context,
  enableAmethystPlugin,
  Event,
} from "@thereallonewolf/amethystframework";

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);

startBot(client);

@Category({
  name: "general",
  description: "My general commands",
  uniqueCommands: true,
  default: "", //As all the commands are unique so no need to set the default command.
})
export class General {
  @Command({
    name: "ping",
    description: "Pong!",
    commandType: ["application", "message"],
    category: "general",
    args: [],
  })
  async ping(bot: AmethystBot, ctx: Context) {
    ctx.reply({ content: "Pong!" });
  }

  @Event("ready")
  async ready() {
    console.log("I am ready!");
    client.amethystUtils.updateSlashCommands();
  }
}
  • 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.
  2. Category Options here
  3. Full Documentation