Fixed Twitch Live notis
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
|
||||
const fetch = require('node-fetch');
|
||||
const api = require('../api');
|
||||
|
||||
module.exports = {
|
||||
name: 'remove-twitchuser',
|
||||
@@ -16,18 +16,14 @@ module.exports = {
|
||||
}
|
||||
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) {
|
||||
const success = await api.deleteTwitchUser(interaction.guildId, username);
|
||||
if (success) {
|
||||
await interaction.reply({ content: `Removed ${username} from watch list.`, flags: 64 });
|
||||
// Refresh cached settings from backend
|
||||
try {
|
||||
const settingsResp = await fetch(`${backendBase}/api/servers/${interaction.guildId}/settings`);
|
||||
if (settingsResp.ok) {
|
||||
const json = await settingsResp.json();
|
||||
const bot = require('..');
|
||||
if (bot && bot.setGuildSettings) bot.setGuildSettings(interaction.guildId, json);
|
||||
}
|
||||
const settings = await api.getServerSettings(interaction.guildId);
|
||||
const bot = require('..');
|
||||
if (bot && bot.setGuildSettings) bot.setGuildSettings(interaction.guildId, settings);
|
||||
} catch (_) {}
|
||||
} else {
|
||||
await interaction.reply({ content: 'Failed to remove user via backend.', flags: 64 });
|
||||
|
||||
Reference in New Issue
Block a user