Added Command Deployment via REST

This commit is contained in:
Sebastian Fischlmayr 2022-10-07 12:02:35 +02:00
parent d032b5dba8
commit abb422c7f1
Signed by: Maverick
GPG key ID: 6379E413924A4E77
4 changed files with 369 additions and 6 deletions

View file

@ -1,2 +1,28 @@
require('dotenv').config();
console.log(process.env)
const { Client, GatewayIntentBits } = require('discord.js');
const token = process.env.TOKEN;
const client = new Client({
intents: [GatewayIntentBits.Guilds]
})
client.once('ready', () => {
console.log('Ready!');
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const commandName = interaction.commandName;
if (commandName === 'ping') {
await interaction.reply('Pong!');
} else if (commandName === 'server') {
await interaction.reply(`Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}`);
} else if (commandName === 'user') {
await interaction.reply(`Your tag: ${interaction.user.tag}\nYour id: ${interaction.user.id}`);
}
})
client.login(token);