mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
moved
This commit is contained in:
parent
4e2b7d1441
commit
9016da2f73
@ -3,26 +3,21 @@ module.exports = {
|
|||||||
raw: true,
|
raw: true,
|
||||||
execute: async (client, interaction) => {
|
execute: async (client, interaction) => {
|
||||||
|
|
||||||
if (interaction.type === 1) {
|
switch (interaction.type) {
|
||||||
|
case 1:
|
||||||
client.log.debug('Received interaction ping, responding with pong');
|
client.log.debug('Received interaction ping, responding with pong');
|
||||||
return await client.api.interactions(interaction.id, interaction.token).callback.post({
|
await client.api.interactions(interaction.id, interaction.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
type: 1,
|
type: 1,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
client.commands.execute(interaction.data.name, interaction);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmd = interaction.data.name;
|
|
||||||
|
|
||||||
if (!client.commands.commands.has(cmd))
|
|
||||||
return client.log.warn(`[COMMANDS] Received "${cmd}" command invocation, but the command manager does not have a "${cmd}" command`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
client.commands.execute(cmd, interaction);
|
|
||||||
} catch (e) {
|
|
||||||
client.log.warn(`[COMMANDS] An error occurred whilst executed the ${cmd} command`);
|
|
||||||
client.log.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -144,7 +144,7 @@ module.exports = class CommandManager {
|
|||||||
*/
|
*/
|
||||||
async execute(cmd_name, interaction) {
|
async execute(cmd_name, interaction) {
|
||||||
if (!this.commands.has(cmd_name))
|
if (!this.commands.has(cmd_name))
|
||||||
throw new Error(`Unregistered command: "${cmd_name}"`);
|
throw new Error(`Received "${cmd_name}" command invocation, but the command manager does not have a "${cmd_name}" command`);
|
||||||
|
|
||||||
let args = {};
|
let args = {};
|
||||||
if (interaction.data.options)
|
if (interaction.data.options)
|
||||||
@ -168,15 +168,18 @@ module.exports = class CommandManager {
|
|||||||
let msg = `❌ You do not have the permissions required to use this command:\n${perms}`;
|
let msg = `❌ You do not have the permissions required to use this command:\n${perms}`;
|
||||||
return await cmd.sendResponse(interaction, msg, true);
|
return await cmd.sendResponse(interaction, msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await cmd.deferResponse(interaction, true);
|
||||||
|
this.client.log.commands(`Executing "${cmd_name}" command (invoked by ${data.member.user.tag})`);
|
||||||
|
let res = await cmd.execute(data, interaction); // run the command
|
||||||
|
if (typeof res === 'object' || typeof res === 'string')
|
||||||
|
cmd.sendResponse(interaction, res, res.secret);
|
||||||
|
} catch (e) {
|
||||||
|
this.client.log.warn(`[COMMANDS] An error occurred whilst executed the ${cmd} command`);
|
||||||
|
this.client.log.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
await cmd.deferResponse(interaction, true);
|
|
||||||
|
|
||||||
this.client.log.commands(`Executing "${cmd_name}" command (invoked by ${data.member.user.tag})`);
|
|
||||||
|
|
||||||
let res = await cmd.execute(data, interaction); // run the command
|
|
||||||
|
|
||||||
if (typeof res === 'object' || typeof res === 'string')
|
|
||||||
cmd.sendResponse(interaction, res, res.secret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user