mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
fix: Ensure promise is returned where applicable
This commit is contained in:
1 parent
f231c53fe8
commit
14cb6b4936
23 files changed
+86
-125
No files matched your search
@@ -26,12 +26,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
guildId: interaction.guild?.id
|
guildId: interaction.guild?.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!client || !client.commands) {
|
const commandList = client!.commands!
|
||||||
logger.error('Client is undefined or does not have commands property.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const commandList = client.commands
|
|
||||||
.filter((command) => {
|
.filter((command) => {
|
||||||
// don't include system commands
|
// don't include system commands
|
||||||
if (command.isSystemCommand) {
|
if (command.isSystemCommand) {
|
||||||
|
|||||||
@@ -39,12 +39,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
let totalTracks: number = 0;
|
let totalTracks: number = 0;
|
||||||
let totalListeners: number = 0;
|
let totalListeners: number = 0;
|
||||||
|
|
||||||
if (!client || !client.shard) {
|
await client!.shard!
|
||||||
logger.error('Client is undefined or does not have shard property.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await client.shard
|
|
||||||
.broadcastEval(() => {
|
.broadcastEval(() => {
|
||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
return player.generateStatistics();
|
return player.generateStatistics();
|
||||||
@@ -73,7 +68,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
logger.error(error, 'Failed to fetch player statistics from shards.');
|
logger.error(error, 'Failed to fetch player statistics from shards.');
|
||||||
});
|
});
|
||||||
|
|
||||||
await client.shard
|
await client!.shard!
|
||||||
.fetchClientValues('guilds.cache')
|
.fetchClientValues('guilds.cache')
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
const guildCaches = results as Guild[][];
|
const guildCaches = results as Guild[][];
|
||||||
@@ -103,7 +98,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
const systemStatusString =
|
const systemStatusString =
|
||||||
`**${uptimeString}** Uptime\n` + `**${cpuUsage}%** CPU usage\n` + `**${usedMemoryInMB} MB** Memory usage`;
|
`**${uptimeString}** Uptime\n` + `**${cpuUsage}%** CPU usage\n` + `**${usedMemoryInMB} MB** Memory usage`;
|
||||||
|
|
||||||
const discordStatusString = `**${client.ws.ping} ms** Discord API latency`;
|
const discordStatusString = `**${client!.ws.ping} ms** Discord API latency`;
|
||||||
|
|
||||||
logger.debug('Transformed status into into embed description.');
|
logger.debug('Transformed status into into embed description.');
|
||||||
|
|
||||||
|
|||||||
@@ -40,21 +40,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queue.deleted) {
|
if (!queue.deleted) {
|
||||||
|
|||||||
@@ -42,17 +42,17 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const loopModesFormatted = new Map([
|
const loopModesFormatted = new Map([
|
||||||
|
|||||||
@@ -48,19 +48,19 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Responding with info embed.');
|
logger.debug('Responding with info embed.');
|
||||||
|
|||||||
@@ -38,21 +38,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceStringsFormatted = new Map([
|
const sourceStringsFormatted = new Map([
|
||||||
|
|||||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentTrack = queue.currentTrack!;
|
const currentTrack = queue.currentTrack!;
|
||||||
|
|||||||
@@ -44,16 +44,16 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await cannotJoinVoiceOrTalk({ interaction, executionId })) {
|
if (await cannotJoinVoiceOrTalk({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
let queue = useQueue(interaction.guild!.id);
|
let queue = useQueue(interaction.guild!.id);
|
||||||
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = useMainPlayer()!;
|
const player = useMainPlayer()!;
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
||||||
|
|||||||
@@ -36,17 +36,17 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeTrackNumber = interaction.options.getNumber('tracknumber')!;
|
const removeTrackNumber = interaction.options.getNumber('tracknumber')!;
|
||||||
|
|||||||
@@ -35,21 +35,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const durationInput = interaction.options.getString('duration');
|
const durationInput = interaction.options.getString('duration');
|
||||||
|
|||||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueIsEmpty({ interaction, queue, executionId })) {
|
if (await queueIsEmpty({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.tracks.shuffle();
|
queue.tracks.shuffle();
|
||||||
|
|||||||
@@ -32,21 +32,21 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const skipToTrack = interaction.options.getNumber('tracknumber');
|
const skipToTrack = interaction.options.getNumber('tracknumber');
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queue.deleted) {
|
if (!queue.deleted) {
|
||||||
|
|||||||
@@ -36,17 +36,17 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const volume = interaction.options.getNumber('percentage');
|
const volume = interaction.options.getNumber('percentage');
|
||||||
|
|||||||
@@ -28,19 +28,14 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
let shardGuilds: Guild[] = [];
|
let shardGuilds: Guild[] = [];
|
||||||
let totalGuildCount = 0;
|
let totalGuildCount = 0;
|
||||||
|
|
||||||
if (!client || !client.shard) {
|
|
||||||
logger.error('Client is undefined or does not have shard property.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Fetching guilds from all shards.');
|
logger.debug('Fetching guilds from all shards.');
|
||||||
await client.shard
|
await client!.shard!
|
||||||
.broadcastEval((c) => {
|
.broadcastEval((c) => {
|
||||||
return c.guilds.cache.map((guild) => {
|
return c.guilds.cache.map((guild) => {
|
||||||
return guild;
|
return guild;
|
||||||
|
|||||||
@@ -29,24 +29,15 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
|
||||||
|
|
||||||
if (!client || !client.shard) {
|
|
||||||
logger.error('Client is undefined or does not have shard property.');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug('Reloading commands across all shards.');
|
logger.debug('Reloading commands across all shards.');
|
||||||
await client.shard
|
await client!
|
||||||
.broadcastEval(
|
.shard!.broadcastEval(
|
||||||
async (shardClient: ExtendedClient, { executionId }) => {
|
async (shardClient: ExtendedClient, { executionId }) => {
|
||||||
if (!shardClient.registerClientCommands) {
|
shardClient.registerClientCommands!({ client: shardClient, executionId });
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
shardClient.registerClientCommands({ client: shardClient, executionId });
|
|
||||||
},
|
},
|
||||||
{ context: { executionId: executionId } }
|
{ context: { executionId: executionId } }
|
||||||
)
|
)
|
||||||
@@ -70,7 +61,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const commands = client.commands?.map((command) => {
|
const commands = client!.commands?.map((command) => {
|
||||||
const params = command.data.options[0] ? `**\`${command.data.options[0].name}\`**` + ' ' : '';
|
const params = command.data.options[0] ? `**\`${command.data.options[0].name}\`**` + ' ' : '';
|
||||||
return `- **\`/${command.data.name}\`** ${params}- ${command.data.description}`;
|
return `- **\`/${command.data.name}\`** ${params}- ${command.data.description}`;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,24 +46,15 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
let shardInfoList: ShardInfo[] = [];
|
let shardInfoList: ShardInfo[] = [];
|
||||||
|
|
||||||
if (!client || !client.shard) {
|
|
||||||
logger.error('Client is undefined or does not have shard property.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Fetching player statistics and client values from each shard.');
|
logger.debug('Fetching player statistics and client values from each shard.');
|
||||||
try {
|
try {
|
||||||
await client.shard
|
await client!
|
||||||
.broadcastEval((shardClient: ExtendedClient) => {
|
.shard!.broadcastEval((shardClient: ExtendedClient) => {
|
||||||
if (!shardClient.shard) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
const playerStats = player.generateStatistics();
|
const playerStats = player.generateStatistics();
|
||||||
const nodeProcessMemUsageInMb = parseFloat(
|
const nodeProcessMemUsageInMb = parseFloat(
|
||||||
@@ -71,7 +62,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const shardInfo = {
|
const shardInfo = {
|
||||||
shardId: shardClient.shard.ids[0],
|
shardId: shardClient.shard!.ids[0],
|
||||||
memUsage: nodeProcessMemUsageInMb,
|
memUsage: nodeProcessMemUsageInMb,
|
||||||
guildCount: shardClient.guilds.cache.size,
|
guildCount: shardClient.guilds.cache.size,
|
||||||
guildMemberCount: shardClient.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0),
|
guildMemberCount: shardClient.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0),
|
||||||
@@ -194,7 +185,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
.setDescription(`**${embedOptions.icons.server} Shard overview - ${shardCount} total shards**\n`)
|
.setDescription(`**${embedOptions.icons.server} Shard overview - ${shardCount} total shards**\n`)
|
||||||
.addFields(...embedFields)
|
.addFields(...embedFields)
|
||||||
.setColor(embedOptions.colors.info)
|
.setColor(embedOptions.colors.info)
|
||||||
.setFooter({ text: `Shard id: ${client.shard.ids[0]}, page ${pageIndex + 1} of ${totalPages}` })
|
.setFooter({ text: `Shard id: ${client!.shard!.ids[0]}, page ${pageIndex + 1} of ${totalPages}` })
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
if (await notValidGuildId({ interaction, executionId })) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// from normal /status command
|
// from normal /status command
|
||||||
@@ -61,13 +61,8 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
|
|
||||||
logger.debug('Fetching player statistics from all shards.');
|
logger.debug('Fetching player statistics from all shards.');
|
||||||
|
|
||||||
if (!client || !client.shard) {
|
await client!
|
||||||
logger.error('Client is undefined or does not have shard property.');
|
.shard!.broadcastEval(() => {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await client.shard
|
|
||||||
.broadcastEval(() => {
|
|
||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
return player.generateStatistics();
|
return player.generateStatistics();
|
||||||
})
|
})
|
||||||
@@ -93,8 +88,8 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
logger.debug('Fetching client values from all shards.');
|
logger.debug('Fetching client values from all shards.');
|
||||||
await client.shard
|
await client!
|
||||||
.fetchClientValues('guilds.cache')
|
.shard!.fetchClientValues('guilds.cache')
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
const guildCaches = results as Guild[][];
|
const guildCaches = results as Guild[][];
|
||||||
guildCaches.map((guildCache: Guild[]) => {
|
guildCaches.map((guildCache: Guild[]) => {
|
||||||
@@ -135,7 +130,7 @@ const command: CustomSlashCommandInteraction = {
|
|||||||
`**${mediaplexVersion}** mediaplex\n` +
|
`**${mediaplexVersion}** mediaplex\n` +
|
||||||
`**${distubeYtdlVersion}** @distube/ytdl-core`;
|
`**${distubeYtdlVersion}** @distube/ytdl-core`;
|
||||||
|
|
||||||
const discordStatusString = `**${client.ws.ping} ms** Discord API latency`;
|
const discordStatusString = `**${client!.ws.ping} ms** Discord API latency`;
|
||||||
|
|
||||||
logger.debug('Transformed system status into embed description.');
|
logger.debug('Transformed system status into embed description.');
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ const component: CustomComponentInteraction = {
|
|||||||
|
|
||||||
logger.info('Received select menu confirmation.');
|
logger.info('Received select menu confirmation.');
|
||||||
|
|
||||||
const queue = useQueue(interaction.guild!.id)!;
|
const selectMenuInteraction = interaction as StringSelectMenuInteraction;
|
||||||
|
const queue = useQueue(selectMenuInteraction.guild!.id)!;
|
||||||
|
|
||||||
queue.filters.ffmpeg.setInputArgs([
|
queue.filters.ffmpeg.setInputArgs([
|
||||||
'-threads',
|
'-threads',
|
||||||
@@ -41,42 +42,39 @@ const component: CustomComponentInteraction = {
|
|||||||
logger.debug('Reset queue filters.');
|
logger.debug('Reset queue filters.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(interaction instanceof StringSelectMenuInteraction)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if bassboost is enabled and not normalizer, also enable normalizer to avoid distrorion
|
// if bassboost is enabled and not normalizer, also enable normalizer to avoid distrorion
|
||||||
if (
|
if (
|
||||||
(interaction.values.includes('bassboost_low') || interaction.values.includes('bassboost')) &&
|
(selectMenuInteraction.values.includes('bassboost_low') || selectMenuInteraction.values.includes('bassboost')) &&
|
||||||
!interaction.values.includes('normalizer')
|
!selectMenuInteraction.values.includes('normalizer')
|
||||||
) {
|
) {
|
||||||
interaction.values.push('normalizer');
|
selectMenuInteraction.values.push('normalizer');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable provided filters
|
// Enable provided filters
|
||||||
queue.filters.ffmpeg.toggle(interaction.values as (keyof QueueFilters)[]);
|
queue.filters.ffmpeg.toggle(selectMenuInteraction.values as (keyof QueueFilters)[]);
|
||||||
logger.debug(`Enabled filters ${interaction.values.join(', ')}.`);
|
logger.debug(`Enabled filters ${selectMenuInteraction.values.join(', ')}.`);
|
||||||
|
|
||||||
let authorName: string;
|
let authorName: string;
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
if (selectMenuInteraction.member instanceof GuildMember) {
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
authorName = selectMenuInteraction.member.nickname || selectMenuInteraction.user.username;
|
||||||
} else {
|
} else {
|
||||||
authorName = interaction.user.username;
|
authorName = selectMenuInteraction.user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await selectMenuInteraction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: authorName,
|
name: authorName,
|
||||||
iconURL: interaction.user.avatarURL() || ''
|
iconURL: selectMenuInteraction.user.avatarURL() || ''
|
||||||
})
|
})
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${
|
`**${
|
||||||
embedOptions.icons.success
|
embedOptions.icons.success
|
||||||
} Filters toggled**\nNow using these filters:\n${interaction.values
|
} Filters toggled**\nNow using these filters:\n${selectMenuInteraction.values
|
||||||
.map((enabledFilter: string) => {
|
.map((enabledFilter: string) => {
|
||||||
const filter = ffmpegFilterOptions.availableFilters.find(
|
const filter = ffmpegFilterOptions.availableFilters.find(
|
||||||
(filter) => enabledFilter == filter.value
|
(filter) => enabledFilter == filter.value
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const postBotStats = async ({ client, executionId }: PostBotStatsParams)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (client.shard?.ids[0] !== 0) {
|
if (client.shard?.ids[0] !== 0) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
let guildCount = 0;
|
let guildCount = 0;
|
||||||
@@ -128,7 +128,8 @@ export const postBotStats = async ({ client, executionId }: PostBotStatsParams)
|
|||||||
|
|
||||||
sites.map((site) => {
|
sites.map((site) => {
|
||||||
if (!site.enabled) {
|
if (!site.enabled) {
|
||||||
return;
|
// return if site is disabled
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const startLoadTest = async ({ client, executionId }: StartLoadTestParams
|
|||||||
|
|
||||||
if (!loadTestOptions.enabled) {
|
if (!loadTestOptions.enabled) {
|
||||||
logger.debug('Load test is disabled in options, cancelling.');
|
logger.debug('Load test is disabled in options, cancelling.');
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const channelIds = loadTestOptions.channelIdsToJoin;
|
const channelIds = loadTestOptions.channelIdsToJoin;
|
||||||
|
|||||||
Reference in new issue
Block a user