fixed themes and ui added new features
This commit is contained in:
@@ -15,6 +15,41 @@ commandHandler(client);
|
||||
eventHandler(client);
|
||||
|
||||
client.on('interactionCreate', async interaction => {
|
||||
// Handle button/component interactions for invites
|
||||
if (interaction.isButton && interaction.isButton()) {
|
||||
const id = interaction.customId || '';
|
||||
if (id.startsWith('copy_inv_')) {
|
||||
const code = id.replace('copy_inv_', '');
|
||||
const db = readDb();
|
||||
const invites = (db[interaction.guildId] && db[interaction.guildId].invites) ? db[interaction.guildId].invites : [];
|
||||
const inv = invites.find(i => i.code === code);
|
||||
if (inv) {
|
||||
await interaction.reply({ content: `Invite: ${inv.url}`, ephemeral: true });
|
||||
} else {
|
||||
await interaction.reply({ content: 'Invite not found.', ephemeral: true });
|
||||
}
|
||||
} else if (id.startsWith('delete_inv_')) {
|
||||
const code = id.replace('delete_inv_', '');
|
||||
// permission check: admin only
|
||||
const member = interaction.member;
|
||||
if (!member.permissions.has('Administrator')) {
|
||||
await interaction.reply({ content: 'You must be an administrator to delete invites.', ephemeral: true });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// call backend delete endpoint
|
||||
const fetch = require('node-fetch');
|
||||
const url = `http://localhost:${process.env.PORT || 3002}/api/servers/${interaction.guildId}/invites/${code}`;
|
||||
await fetch(url, { method: 'DELETE' });
|
||||
await interaction.reply({ content: 'Invite deleted.', ephemeral: true });
|
||||
} catch (e) {
|
||||
console.error('Error deleting invite via API:', e);
|
||||
await interaction.reply({ content: 'Failed to delete invite.', ephemeral: true });
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!interaction.isCommand()) return;
|
||||
|
||||
const command = client.commands.get(interaction.commandName);
|
||||
|
||||
Reference in New Issue
Block a user