feat: Finish bot v1

This commit is contained in:
2024-02-26 14:45:34 +01:00
parent b23f6ffac6
commit 8ac3deace3
12 changed files with 307 additions and 10 deletions

10
commands/utility/ping.js Normal file
View File

@ -0,0 +1,10 @@
const { SlashCommandBuilder } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong'),
async execute(interaction) {
await interaction.reply('Pong')
},
}

View File

@ -0,0 +1,32 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
category: 'utility',
data: new SlashCommandBuilder()
.setName('reload')
.setDescription('Reloads a command.')
.addStringOption(option =>
option.setName('command')
.setDescription('The command to reload.')
.setRequired(true)),
async execute(interaction) {
const commandName = interaction.options.getString('command', true).toLowerCase();
const command = interaction.client.commands.get(commandName);
if (!command) {
return interaction.reply(`There is no command with name \`${commandName}\`!`);
}
delete require.cache[require.resolve(`../${command.category}/${command.data.name}.js`)];
try {
await interaction.client.commands.delete(command.data.name);
const newCommand = require(`../${command.category}/${command.data.name}.js`);
await interaction.client.commands.set(newCommand.data.name, newCommand);
await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`);
} catch (error) {
console.error(error);
await interaction.reply(`There was an error while reloading a command \`${command.data.name}\`:\n\`${error.message}\``);
}
},
};

View File

@ -0,0 +1,11 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('server')
.setDescription('Provides information about the server.'),
async execute(interaction) {
// interaction.guild is the object representing the Guild in which the command was run
await interaction.reply(`This server is ${interaction.guild.name} and has ${interaction.guild.memberCount} members.`);
},
};

12
commands/utility/user.js Normal file
View File

@ -0,0 +1,12 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction) {
// interaction.user is the object representing the User who ran the command
// interaction.member is the GuildMember object, which represents the user in the specific guild
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
},
};