mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
fix: Updated sending in checks for validation runner
This commit is contained in:
1 parent
8da6f44ebb
commit
56056cd73d
17 files changed
+76
-110
No files matched your search
@@ -41,13 +41,6 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args),
|
||||
(args) => checkQueueCurrentTrack(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -56,7 +49,12 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists,
|
||||
checkQueueCurrentTrack
|
||||
]);
|
||||
|
||||
const filterProvider: string = interaction.options.getString('type') || 'FFmpeg';
|
||||
|
||||
|
||||
@@ -11,12 +11,6 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
.setName('leave')
|
||||
.setDescription('Clear the queue and remove bot from voice channel.');
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -25,7 +19,11 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists
|
||||
]);
|
||||
|
||||
logger.info('Validators passed, clearing queue.');
|
||||
|
||||
|
||||
@@ -23,12 +23,6 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -37,7 +31,11 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists
|
||||
]);
|
||||
|
||||
// TODO: create type for loop modes formatted
|
||||
const loopModesFormatted: Map<number, string> = new Map([
|
||||
|
||||
@@ -21,13 +21,6 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
.setAutocomplete(true)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args),
|
||||
(args) => checkQueueCurrentTrack(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -40,7 +33,12 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
let geniusSearchQuery: string = '';
|
||||
|
||||
if (!query) {
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists,
|
||||
checkQueueCurrentTrack
|
||||
]);
|
||||
|
||||
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
||||
|
||||
|
||||
@@ -24,13 +24,6 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
.setName('nowplaying')
|
||||
.setDescription('Show information about the current track.');
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args),
|
||||
(args) => checkQueueCurrentTrack(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -39,7 +32,12 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists,
|
||||
checkQueueCurrentTrack
|
||||
]);
|
||||
|
||||
const sourceStringsFormatted: Map<string, string> = new Map([
|
||||
['youtube', 'YouTube'],
|
||||
|
||||
@@ -9,13 +9,6 @@ class PauseCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder().setName('pause').setDescription('Toggle pause for the current track.');
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args),
|
||||
(args) => checkQueueCurrentTrack(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -24,7 +17,12 @@ class PauseCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists,
|
||||
checkQueueCurrentTrack
|
||||
]);
|
||||
|
||||
const currentTrack: Track = queue.currentTrack!;
|
||||
|
||||
|
||||
@@ -25,15 +25,13 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
.setAutocomplete(true)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [(args) => checkInVoiceChannel(args)];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId });
|
||||
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel]);
|
||||
|
||||
let queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
if (queue) {
|
||||
|
||||
@@ -18,12 +18,6 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
option.setName('page').setDescription('Page number to display for the queue').setMinValue(1)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -32,7 +26,11 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists
|
||||
]);
|
||||
|
||||
const pageIndex: number = (interaction.options.getNumber('page') || 1) - 1;
|
||||
let queueString: string = '';
|
||||
|
||||
@@ -18,12 +18,6 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
.setRequired(true)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -32,7 +26,11 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists
|
||||
]);
|
||||
|
||||
const removeTrackNumber: number = interaction.options.getNumber('tracknumber')!;
|
||||
|
||||
|
||||
@@ -14,13 +14,6 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
option.setName('duration').setDescription('Duration in format 00:00:00 (HH:mm:ss).').setRequired(true)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args),
|
||||
(args) => checkQueueCurrentTrack(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -29,7 +22,12 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists,
|
||||
checkQueueCurrentTrack
|
||||
]);
|
||||
|
||||
const durationInput: string = interaction.options.getString('duration')!;
|
||||
|
||||
|
||||
@@ -11,13 +11,6 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
||||
.setName('shuffle')
|
||||
.setDescription('Randomly shuffle all tracks in the queue.');
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args),
|
||||
(args) => checkQueueEmpty(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -26,7 +19,12 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists,
|
||||
checkQueueEmpty
|
||||
]);
|
||||
|
||||
queue.tracks.shuffle();
|
||||
logger.debug('Shuffled queue tracks.');
|
||||
|
||||
@@ -14,13 +14,6 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
option.setName('tracknumber').setDescription('The position in queue to skip to.').setMinValue(1)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args),
|
||||
(args) => checkQueueCurrentTrack(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -29,7 +22,12 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists,
|
||||
checkQueueCurrentTrack
|
||||
]);
|
||||
|
||||
const skipToTrack: number = interaction.options.getNumber('tracknumber')!;
|
||||
|
||||
|
||||
@@ -11,12 +11,6 @@ class StopCommand extends BaseSlashCommandInteraction {
|
||||
.setName('stop')
|
||||
.setDescription('Clear the queue and stop playing audio.');
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -25,7 +19,11 @@ class StopCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists
|
||||
]);
|
||||
|
||||
if (!queue.deleted) {
|
||||
queue.setRepeatMode(0);
|
||||
|
||||
@@ -18,12 +18,6 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
.setMaxValue(100)
|
||||
);
|
||||
super(data);
|
||||
|
||||
this.validators = [
|
||||
(args) => checkInVoiceChannel(args),
|
||||
(args) => checkSameVoiceChannel(args),
|
||||
(args) => checkQueueExists(args)
|
||||
];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
@@ -32,7 +26,11 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
await this.runValidators({ interaction, queue, executionId });
|
||||
await this.runValidators({ interaction, queue, executionId }, [
|
||||
checkInVoiceChannel,
|
||||
checkSameVoiceChannel,
|
||||
checkQueueExists
|
||||
]);
|
||||
|
||||
const volume: number = interaction.options.getNumber('percentage')!;
|
||||
|
||||
|
||||
@@ -10,15 +10,13 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
||||
.setDescription('Show the top 25 guilds by member count.');
|
||||
const isSystemCommand: boolean = true;
|
||||
super(data, isSystemCommand);
|
||||
|
||||
this.validators = [(args) => checkValidGuildId(args)];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId });
|
||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||
|
||||
let shardGuilds: Guild[] = [];
|
||||
let totalGuildCount: number = 0;
|
||||
|
||||
@@ -11,15 +11,13 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
.setDescription('Reload slash command, autocomplete and component interactions across shards.');
|
||||
const isSystemCommand: boolean = true;
|
||||
super(data, isSystemCommand);
|
||||
|
||||
this.validators = [(args) => checkValidGuildId(args)];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId });
|
||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||
|
||||
try {
|
||||
logger.debug('Reloading interaction module across all shards.');
|
||||
|
||||
@@ -29,15 +29,13 @@ class ShardsCommand extends BaseSlashCommandInteraction {
|
||||
);
|
||||
const isSystemCommand: boolean = true;
|
||||
super(data, isSystemCommand);
|
||||
|
||||
this.validators = [(args) => checkValidGuildId(args)];
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction, client } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
|
||||
await this.runValidators({ interaction, executionId });
|
||||
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
|
||||
|
||||
let shardInfoList: ShardInfo[] = [];
|
||||
|
||||
|
||||
Reference in new issue
Block a user