1.2.2 • Published 2 years ago
hesperus v1.2.2
Installation
In order to use this library, you need Node.js 16.9.x or higher.
# Installing via npm
npm install hesperus
# Installing via yarn
yarn add hesperus
# Installing via pnpm
pnpm install hesperus
Example usage
Put this code into your main file (like index.js
or src/index.js
):
const {Client, Intents} = require('discord.js')
const {Hesperus} = require('hesperus')
const client = new Client({intents: [/* Put here required Intents for your bot. */]})
new Hesperus(client, {
rootDir: __dirname,
botOwners: ['PUT_YOUR_USER_ID_HERE'],
guildIds: ['PUT_GUILD_ID_HERE'],
})
client.login('...')
This will enable deploying your commands to the Discord API.
After that, put this code into commands/hello.js
:
const {SlashCommand} = require('hesperus')
module.exports = new SlashCommand({
name: 'hello',
description: 'Replies with "Hello, World".',
callback: async (client, interaction) => {
await interaction.reply('Hello, World.')
}
})
This is your first command! It will reply to your message with Hello, World!
text.
You can put this code into events/ready.js
, if you want to register ready
event.
const {Event} = require('hesperus')
module.exports = new Event({
name: 'ready',
once: true,
async callback(client) {
console.log(`Logged in as ${client.user.tag}!`) // You can specify any message that you want.
}
})