Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lassejlv/easydisbot-js
https://github.com/lassejlv/easydisbot-js
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lassejlv/easydisbot-js
- Owner: lassejlv
- Created: 2023-03-06T15:54:56.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T16:35:27.000Z (almost 2 years ago)
- Last Synced: 2024-11-08T20:16:41.876Z (2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# easydisbot.js
Simple and flexible discord bot framework for node.js
### Install
```bash
npm install easy-discord-bot.js
```### Example
```js
const { DiscordBot } = require("easy-disbot.js");const bot = new DiscordBot(process.env.TOKEN);
bot.on("READY", (client) => {
console.log(
`Logged in as ${client.user.username}#${client.user.discriminator}!`
);
});bot.on("MESSAGE_CREATE", async (message) => {
// Extract the channel ID and message content from the message object
const { guild_id, channel_id } = message;// Reply to the message with the same content
await bot.sendMessage(guild_id, channel_id, "Hello World!");// Send Embed
// Import the EmbedBuilder class from the easydisbot.js
const { EmbedBuilder } = require("easydisbot.js");const embed = new EmbedBuilder()
.setTitle("Hello World!")
.setDescription("This is a description");await bot.sendMessage(guild_id, channel_id, embed.build());
// Delete the message (only works if the bot has the MANAGE_MESSAGES permission)
// We recommed to put it in a try catch, because there is a chance that the bot throws an error
try {
await bot.deleteMessage(guild_id, channel_id, message.id);
} catch (error) {
console.log(error);
}
});bot.connect();
```