fix: implement clear cmd
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
|
import { ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
|
||||||
import { Command } from '../../commands';
|
import { Command } from '../../commands';
|
||||||
|
import { getVoiceConnection, VoiceConnectionStatus } from '@discordjs/voice';
|
||||||
|
import { AudioStreamManager } from '../../modules/audiostreams';
|
||||||
|
|
||||||
const builder = new SlashCommandBuilder()
|
const builder = new SlashCommandBuilder()
|
||||||
.setName('tts-clear')
|
.setName('tts-clear')
|
||||||
@@ -10,11 +12,19 @@ const cmd: Command = {
|
|||||||
builder: builder,
|
builder: builder,
|
||||||
requiresAdmin: true,
|
requiresAdmin: true,
|
||||||
execute: async (interaction: ChatInputCommandInteraction): Promise<void> => {
|
execute: async (interaction: ChatInputCommandInteraction): Promise<void> => {
|
||||||
if (!interaction.guildId) {
|
if (!interaction.guild) {
|
||||||
interaction.reply('This command only works on Guilds');
|
interaction.reply('This command only works on Guilds');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const voiceConnection = getVoiceConnection(interaction.guild.id);
|
||||||
|
if (voiceConnection?.state.status !== VoiceConnectionStatus.Ready) return;
|
||||||
|
|
||||||
|
const stream = AudioStreamManager.get.getOrCreateStream(voiceConnection);
|
||||||
|
|
||||||
|
const queue = stream.getQueue('TTS');
|
||||||
|
queue.clear();
|
||||||
|
|
||||||
interaction.reply('Queue cleared.');
|
interaction.reply('Queue cleared.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user