mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +00:00
Add class for interactions
This commit is contained in:
1 parent
d0f1e940a5
commit
b96a73df6f
37 files changed
+1038
-1012
No files matched your search
@@ -1,32 +1,24 @@
|
||||
import config from 'config';
|
||||
import { GuildQueue, useQueue } from 'discord-player';
|
||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from '../../../services/logger';
|
||||
import { EmbedOptions } from '../../../types/configTypes';
|
||||
import { CustomSlashCommandInteraction } from '../../../types/interactionTypes';
|
||||
import {
|
||||
BaseSlashCommandInteraction,
|
||||
BaseSlashCommandParams,
|
||||
BaseSlashCommandReturnType
|
||||
} from '../../../types/interactionTypes';
|
||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName('leave')
|
||||
.setDescription('Clear the queue and remove bot from voice channel.');
|
||||
super(data);
|
||||
}
|
||||
|
||||
const command: CustomSlashCommandInteraction = {
|
||||
isNew: false,
|
||||
isBeta: false,
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('leave')
|
||||
.setDescription('Clear the track queue and remove the bot from voice channel.')
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, executionId }) => {
|
||||
const logger: Logger = loggerModule.child({
|
||||
source: 'leave.js',
|
||||
module: 'slashCommand',
|
||||
name: '/leave',
|
||||
executionId: executionId,
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -61,15 +53,15 @@ const command: CustomSlashCommandInteraction = {
|
||||
new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: authorName,
|
||||
iconURL: interaction.user.avatarURL() || embedOptions.info.fallbackIconUrl
|
||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
||||
})
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!`
|
||||
`**${this.embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!`
|
||||
)
|
||||
.setColor(embedOptions.colors.success)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default command;
|
||||
export default new LeaveCommand();
|
||||
Reference in new issue
Block a user