swapped to a new db locally hosted
This commit is contained in:
31
discord-bot/commands/remove-twitchuser.js
Normal file
31
discord-bot/commands/remove-twitchuser.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
module.exports = {
|
||||
name: 'remove-twitchuser',
|
||||
description: 'Admin: remove a Twitch username from this server watch list',
|
||||
enabled: true,
|
||||
builder: new SlashCommandBuilder()
|
||||
.setName('remove-twitchuser')
|
||||
.setDescription('Remove a Twitch username from the watch list')
|
||||
.addStringOption(opt => opt.setName('username').setDescription('Twitch username to remove').setRequired(true)),
|
||||
async execute(interaction) {
|
||||
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
|
||||
await interaction.reply({ content: 'You must be an administrator to use this command.', flags: 64 });
|
||||
return;
|
||||
}
|
||||
const username = interaction.options.getString('username').toLowerCase().trim();
|
||||
try {
|
||||
const backendBase = process.env.BACKEND_BASE || `http://${process.env.HOST || '127.0.0.1'}:${process.env.PORT || 3002}`;
|
||||
const resp = await fetch(`${backendBase}/api/servers/${interaction.guildId}/twitch-users/${encodeURIComponent(username)}`, { method: 'DELETE' });
|
||||
if (resp.ok) {
|
||||
await interaction.reply({ content: `Removed ${username} from watch list.`, flags: 64 });
|
||||
} else {
|
||||
await interaction.reply({ content: 'Failed to remove user via backend.', flags: 64 });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error removing twitch user:', e);
|
||||
await interaction.reply({ content: 'Internal error removing twitch user.', flags: 64 });
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user