- Updated from Discord.js 12 to Discord.js 14
This commit is contained in:
parent
85a778bfc0
commit
395839d7aa
4 changed files with 18 additions and 2 deletions
|
@ -5,6 +5,6 @@ module.exports = {
|
|||
.setName('ping')
|
||||
.setDescription('Replies with Pong!'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply('Pong!');
|
||||
await interaction.reply({ content: 'Secret Pong!', ephemeral: true });
|
||||
},
|
||||
};
|
||||
|
|
|
@ -7,6 +7,6 @@ module.exports = {
|
|||
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}.`);
|
||||
await interaction.reply(`This command was run by ${interaction.user.username}, who joined this ${interaction.guild.name} on ${interaction.member.joinedAt}.`);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
#!/bin/bash
|
||||
node deploy-commands.js
|
||||
node index.js
|
15
index.js
15
index.js
|
@ -7,6 +7,7 @@ const { token } = require('./config.json');
|
|||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||
|
||||
//COMMANDS
|
||||
|
||||
client.commands = new Collection();
|
||||
|
||||
const commandsPath = path.join(__dirname, 'commands');
|
||||
|
@ -42,7 +43,21 @@ client.on(Events.InteractionCreate, async interaction => {
|
|||
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||
}
|
||||
}
|
||||
client.cooldowns = new Collection();
|
||||
const { cooldowns } = client;
|
||||
|
||||
if (!cooldowns.has(command.data.name)) {
|
||||
cooldowns.set(command.data.name, new Collection());
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
const timestamps = cooldowns.get(command.data.name);
|
||||
const defaultCooldownDuration = 3;
|
||||
const cooldownAmount = (command.cooldown ?? defaultCooldownDuration) * 1000;
|
||||
|
||||
if (timestamps.has(interaction.user.id)) {
|
||||
// ...
|
||||
}
|
||||
console.log(interaction);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue