shazai
DIAdiscord.js - Imagine an app
•Created by Harrison on 11/7/2023 in #djs-questions
Updating ephemeral
interactionCreate.js
38 replies
DIAdiscord.js - Imagine an app
•Created by Harrison on 11/7/2023 in #djs-questions
Updating ephemeral
module.exports = {
name: 'interactionCreate',
enabled: true,
async execute(client, interaction) {
if (!interaction.isCommand()) return;
await interaction.deferReply();
const member = interaction.guild.members.cache.get(interaction.user.id);
const command = interaction.client.commands.get(interaction.commandName);
if (!command) return;
const rows = await interaction.client.database.selectData('profiles', `user_id = ${member.id}`);
interaction.client.database.insertData('profiles', { user_id: member.id, blacklisted: 0})
if (rows[0] && rows[0].blacklisted == 1 && !member.permissions.has('ADMINISTRATOR')) {
editEmbedInteraction(interaction, blacklisted);
setTimeout(() => interaction.deleteReply(), 3000);
return;
}
hasPermission = false;
try {
if (command.roles.length == 0) hasPermission = true;
if (member.roles.cache.some((role) => command.roles.includes(role.name)
|| command.roles.includes(role.id))) hasPermission = true;
if (hasPermission != true) {
editEmbedInteraction(interaction, 'Invalid Permission', '', '', '', 'You don\'t have the correct permissions to use this command.')
setTimeout(() => interaction.deleteReply(), 3000);
return;
}
await command.execute(interaction);
} catch (error) {
if (error) {
console.error(error);
editEmbedInteraction(interaction, 'Command Error', '', '', '', `There was an error whilst executing this command:\n${error}`)
return;
}
}
},
};
module.exports = {
name: 'interactionCreate',
enabled: true,
async execute(client, interaction) {
if (!interaction.isCommand()) return;
await interaction.deferReply();
const member = interaction.guild.members.cache.get(interaction.user.id);
const command = interaction.client.commands.get(interaction.commandName);
if (!command) return;
const rows = await interaction.client.database.selectData('profiles', `user_id = ${member.id}`);
interaction.client.database.insertData('profiles', { user_id: member.id, blacklisted: 0})
if (rows[0] && rows[0].blacklisted == 1 && !member.permissions.has('ADMINISTRATOR')) {
editEmbedInteraction(interaction, blacklisted);
setTimeout(() => interaction.deleteReply(), 3000);
return;
}
hasPermission = false;
try {
if (command.roles.length == 0) hasPermission = true;
if (member.roles.cache.some((role) => command.roles.includes(role.name)
|| command.roles.includes(role.id))) hasPermission = true;
if (hasPermission != true) {
editEmbedInteraction(interaction, 'Invalid Permission', '', '', '', 'You don\'t have the correct permissions to use this command.')
setTimeout(() => interaction.deleteReply(), 3000);
return;
}
await command.execute(interaction);
} catch (error) {
if (error) {
console.error(error);
editEmbedInteraction(interaction, 'Command Error', '', '', '', `There was an error whilst executing this command:\n${error}`)
return;
}
}
},
};
38 replies