diff --git a/commands/ping.js b/commands/ping.js index 64e2ba6..a83cd80 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -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 }); }, }; diff --git a/commands/user.js b/commands/user.js index 6ef0ba8..704455e 100644 --- a/commands/user.js +++ b/commands/user.js @@ -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}.`); }, }; diff --git a/discordbot.sh b/discordbot.sh index d1f4fdf..48d6e90 100755 --- a/discordbot.sh +++ b/discordbot.sh @@ -1,2 +1,3 @@ #!/bin/bash +node deploy-commands.js node index.js \ No newline at end of file diff --git a/index.js b/index.js index a9c1dd3..60a11d3 100644 --- a/index.js +++ b/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); });