TomerRon / cordless

🤖 Declarative Discord bot framework. Build your first bot in 5 minutes with 3 lines of code!
ISC License
57 stars 2 forks source link

feat(commands): Add base Application Commands integration #28

Closed TomerRon closed 2 years ago

TomerRon commented 2 years ago

This PR adds Application Commands to cordless, allowing bots to register commands and react to them. For now, only basic interactions are possible. Future PRs will add additional features like accepting options, responding with interactive buttons, and more.


Basic Commands usage

const ping: BotCommand = {
  name: "ping",
  description: "Replies to your ping.",
  handler: ({ interaction }) =>
    interaction.reply({
      content: "Pong!",
    }),
};

init({
  applicationId: process.env.APPLICATION_ID,
  commands: [ping],
  functions: [],
  token: process.env.BOT_TOKEN || "",
});

Note: your bot's application ID can be found in the Discord developer portal. It's only required if you are using commands.


Breaking changes

Previous:

init({ functions: [...] }).login(process.env.BOT_TOKEN)

New:

init({
  functions: [...],
  token: process.env.BOT_TOKEN || "",
});
TomerRon commented 2 years ago

:tada: This PR is included in version 3.0.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

TomerRon commented 2 years ago

:tada: This PR is included in version 3.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: