mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +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
|
||||
});
|
||||
|
||||
if (!client || !client.commands) {
|
||||
logger.error('Client is undefined or does not have commands property.');
|
||||
return;
|
||||
}
|
||||
|
||||
const commandList = client.commands
|
||||
const commandList = client!.commands!
|
||||
.filter((command) => {
|
||||
// don't include system commands
|
||||
if (command.isSystemCommand) {
|
||||
|
||||
@@ -39,12 +39,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
let totalTracks: number = 0;
|
||||
let totalListeners: number = 0;
|
||||
|
||||
if (!client || !client.shard) {
|
||||
logger.error('Client is undefined or does not have shard property.');
|
||||
return;
|
||||
}
|
||||
|
||||
await client.shard
|
||||
await client!.shard!
|
||||
.broadcastEval(() => {
|
||||
/* eslint-disable no-undef */
|
||||
return player.generateStatistics();
|
||||
@@ -73,7 +68,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
logger.error(error, 'Failed to fetch player statistics from shards.');
|
||||
});
|
||||
|
||||
await client.shard
|
||||
await client!.shard!
|
||||
.fetchClientValues('guilds.cache')
|
||||
.then((results) => {
|
||||
const guildCaches = results as Guild[][];
|
||||
@@ -103,7 +98,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
const systemStatusString =
|
||||
`**${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.');
|
||||
|
||||
|
||||
@@ -40,21 +40,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
|
||||
@@ -28,7 +28,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (!queue.deleted) {
|
||||
|
||||
@@ -42,17 +42,17 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const loopModesFormatted = new Map([
|
||||
|
||||
@@ -48,19 +48,19 @@ const command: CustomSlashCommandInteraction = {
|
||||
|
||||
if (!query) {
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
||||
|
||||
@@ -188,7 +188,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
logger.debug('Responding with info embed.');
|
||||
|
||||
@@ -38,21 +38,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const sourceStringsFormatted = new Map([
|
||||
|
||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const currentTrack = queue.currentTrack!;
|
||||
|
||||
@@ -44,16 +44,16 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await cannotJoinVoiceOrTalk({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let queue = useQueue(interaction.guild!.id);
|
||||
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const player = useMainPlayer()!;
|
||||
|
||||
@@ -30,13 +30,13 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const pageIndex = (interaction.options.getNumber('page') || 1) - 1;
|
||||
|
||||
@@ -36,17 +36,17 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const removeTrackNumber = interaction.options.getNumber('tracknumber')!;
|
||||
|
||||
@@ -35,21 +35,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const durationInput = interaction.options.getString('duration');
|
||||
|
||||
@@ -29,21 +29,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueIsEmpty({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
queue.tracks.shuffle();
|
||||
|
||||
@@ -32,21 +32,21 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await queueNoCurrentTrack({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const skipToTrack = interaction.options.getNumber('tracknumber');
|
||||
|
||||
@@ -28,7 +28,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
@@ -49,7 +49,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (!queue.deleted) {
|
||||
|
||||
@@ -36,17 +36,17 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notInVoiceChannel({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const queue: NodeResolvable = useQueue(interaction.guild!.id)!;
|
||||
|
||||
if (await queueDoesNotExist({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (await notInSameVoiceChannel({ interaction, queue, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const volume = interaction.options.getNumber('percentage');
|
||||
|
||||
@@ -28,19 +28,14 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notValidGuildId({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let shardGuilds: Guild[] = [];
|
||||
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.');
|
||||
await client.shard
|
||||
await client!.shard!
|
||||
.broadcastEval((c) => {
|
||||
return c.guilds.cache.map((guild) => {
|
||||
return guild;
|
||||
|
||||
@@ -29,24 +29,15 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notValidGuildId({ interaction, executionId })) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!client || !client.shard) {
|
||||
logger.error('Client is undefined or does not have shard property.');
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
try {
|
||||
logger.debug('Reloading commands across all shards.');
|
||||
await client.shard
|
||||
.broadcastEval(
|
||||
await client!
|
||||
.shard!.broadcastEval(
|
||||
async (shardClient: ExtendedClient, { executionId }) => {
|
||||
if (!shardClient.registerClientCommands) {
|
||||
return;
|
||||
}
|
||||
|
||||
shardClient.registerClientCommands({ client: shardClient, executionId });
|
||||
shardClient.registerClientCommands!({ client: shardClient, 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}\`**` + ' ' : '';
|
||||
return `- **\`/${command.data.name}\`** ${params}- ${command.data.description}`;
|
||||
});
|
||||
|
||||
@@ -46,24 +46,15 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
if (await notValidGuildId({ interaction, executionId })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
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.');
|
||||
try {
|
||||
await client.shard
|
||||
.broadcastEval((shardClient: ExtendedClient) => {
|
||||
if (!shardClient.shard) {
|
||||
return;
|
||||
}
|
||||
|
||||
await client!
|
||||
.shard!.broadcastEval((shardClient: ExtendedClient) => {
|
||||
/* eslint-disable no-undef */
|
||||
const playerStats = player.generateStatistics();
|
||||
const nodeProcessMemUsageInMb = parseFloat(
|
||||
@@ -71,7 +62,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
);
|
||||
|
||||
const shardInfo = {
|
||||
shardId: shardClient.shard.ids[0],
|
||||
shardId: shardClient.shard!.ids[0],
|
||||
memUsage: nodeProcessMemUsageInMb,
|
||||
guildCount: shardClient.guilds.cache.size,
|
||||
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`)
|
||||
.addFields(...embedFields)
|
||||
.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 })) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// from normal /status command
|
||||
@@ -61,13 +61,8 @@ const command: CustomSlashCommandInteraction = {
|
||||
|
||||
logger.debug('Fetching player statistics from all shards.');
|
||||
|
||||
if (!client || !client.shard) {
|
||||
logger.error('Client is undefined or does not have shard property.');
|
||||
return;
|
||||
}
|
||||
|
||||
await client.shard
|
||||
.broadcastEval(() => {
|
||||
await client!
|
||||
.shard!.broadcastEval(() => {
|
||||
/* eslint-disable no-undef */
|
||||
return player.generateStatistics();
|
||||
})
|
||||
@@ -93,8 +88,8 @@ const command: CustomSlashCommandInteraction = {
|
||||
});
|
||||
|
||||
logger.debug('Fetching client values from all shards.');
|
||||
await client.shard
|
||||
.fetchClientValues('guilds.cache')
|
||||
await client!
|
||||
.shard!.fetchClientValues('guilds.cache')
|
||||
.then((results) => {
|
||||
const guildCaches = results as Guild[][];
|
||||
guildCaches.map((guildCache: Guild[]) => {
|
||||
@@ -135,7 +130,7 @@ const command: CustomSlashCommandInteraction = {
|
||||
`**${mediaplexVersion}** mediaplex\n` +
|
||||
`**${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.');
|
||||
|
||||
|
||||
Reference in new issue
Block a user