mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
Merge pull request #176 from mariusbegby/v4-improvements-continued
V4 improvements continued
This commit is contained in:
3 files changed
+46
-23
No files matched your search
@@ -81,22 +81,34 @@ module.exports = {
|
|||||||
const evenShardIndexesString = evenShardIndexes.map(shardInfoToString).join('\n') + 'ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ';
|
const evenShardIndexesString = evenShardIndexes.map(shardInfoToString).join('\n') + 'ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ';
|
||||||
const oddShardIndexesString = oddShardIndexes.map(shardInfoToString).join('\n');
|
const oddShardIndexesString = oddShardIndexes.map(shardInfoToString).join('\n');
|
||||||
|
|
||||||
|
const embedFields = [];
|
||||||
|
|
||||||
|
if (currentPageShards.length === 1) {
|
||||||
|
embedFields.push({
|
||||||
|
name: ' ',
|
||||||
|
value: currentPageShards.map(shardInfoToString).join('\n'),
|
||||||
|
inline: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
embedFields.push(
|
||||||
|
{
|
||||||
|
name: ' ',
|
||||||
|
value: evenShardIndexesString,
|
||||||
|
inline: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: ' ',
|
||||||
|
value: oddShardIndexesString,
|
||||||
|
inline: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(`**${embedOptions.icons.server} Shard overview - ${shardCount} total shards**\n`)
|
.setDescription(`**${embedOptions.icons.server} Shard overview - ${shardCount} total shards**\n`)
|
||||||
.addFields(
|
.addFields(...embedFields)
|
||||||
{
|
|
||||||
name: ' ',
|
|
||||||
value: evenShardIndexesString,
|
|
||||||
inline: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: ' ',
|
|
||||||
value: oddShardIndexesString,
|
|
||||||
inline: true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.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}` })
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -9,16 +9,27 @@ module.exports = {
|
|||||||
name: Events.InteractionCreate,
|
name: Events.InteractionCreate,
|
||||||
isDebug: false,
|
isDebug: false,
|
||||||
execute: async (interaction, { client }) => {
|
execute: async (interaction, { client }) => {
|
||||||
|
if (interaction.isMessageComponent()) {
|
||||||
|
logger.info(
|
||||||
|
`[Shard ${interaction.guild.shardId}] Guild ${
|
||||||
|
interaction.guild.id
|
||||||
|
}> Message component interaction created for id ${interaction.customId}${
|
||||||
|
interaction.values ? ' and values ' + interaction.values : ''
|
||||||
|
}.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const command = client.commands.get(interaction.commandName);
|
const command = client.commands.get(interaction.commandName);
|
||||||
if (!command) {
|
if (!command) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[Shard ${interaction.guild.shardId}] Interaction created but command '${interaction.commandName}' was not found.`
|
`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction created but command '${interaction.commandName}' was not found.`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.isAutocomplete()) {
|
if (interaction.isAutocomplete()) {
|
||||||
logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete created.`);
|
logger.debug(`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Autocomplete created.`);
|
||||||
try {
|
try {
|
||||||
await command.autocomplete({ interaction, client });
|
await command.autocomplete({ interaction, client });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -27,7 +38,7 @@ module.exports = {
|
|||||||
error.message === 'Interaction has already been acknowledged.'
|
error.message === 'Interaction has already been acknowledged.'
|
||||||
) {
|
) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`[Shard ${interaction.guild.shardId}] Autocomplete failed to be responded to, unknown interaction or already acknowledged.`
|
`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Autocomplete failed to be responded to, unknown interaction or already acknowledged.`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -36,11 +47,10 @@ module.exports = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (interaction.isChatInputCommand()) {
|
} else if (interaction.isChatInputCommand()) {
|
||||||
logger.debug(`[Shard ${interaction.guild.shardId}] Interaction created.`);
|
logger.debug(`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction created.`);
|
||||||
try {
|
try {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
// causing issues with unknown interaction error?
|
|
||||||
if (await cannotSendMessageInChannel(interaction)) {
|
if (await cannotSendMessageInChannel(interaction)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,7 +72,7 @@ module.exports = {
|
|||||||
|
|
||||||
if (!interaction.deferred || !interaction.replied) {
|
if (!interaction.deferred || !interaction.replied) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[Shard ${interaction.guild.shardId}] Interaction was not deferred or replied to, and an error was thrown.`
|
`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction was not deferred or replied to, and an error was thrown.`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -72,7 +82,7 @@ module.exports = {
|
|||||||
return;
|
return;
|
||||||
} else if (interaction.deferred) {
|
} else if (interaction.deferred) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`[Shard ${interaction.guild.shardId}] Interaction was deferred, editing reply and sending Uh-oh message.`
|
`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction was deferred, editing reply and sending Uh-oh message.`
|
||||||
);
|
);
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -85,7 +95,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logger.info(
|
logger.info(
|
||||||
`[Shard ${interaction.guild.shardId}] Interaction was not deferred or replied, sending new reply with Uh-oh message.`
|
`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction was not deferred or replied, sending new reply with Uh-oh message.`
|
||||||
);
|
);
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -101,7 +111,7 @@ module.exports = {
|
|||||||
} else {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
interaction,
|
interaction,
|
||||||
`[Shard ${interaction.guild.shardId}] Interaction created but was not a chat input or autocomplete interaction.`
|
`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction created but was not a chat input or autocomplete interaction.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ exports.notInVoiceChannel = async (interaction) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.notInSameVoiceChannel = async (interaction, queue) => {
|
exports.notInSameVoiceChannel = async (interaction, queue) => {
|
||||||
if (!queue.dispatcher) {
|
if (!queue || !queue.dispatcher) {
|
||||||
return true;
|
// If there is no queue or bot is not in voice channel, then there is no need to check if user is in same voice channel.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.member.voice.channel.id !== queue.dispatcher.channel.id) {
|
if (interaction.member.voice.channel.id !== queue.dispatcher.channel.id) {
|
||||||
|
|||||||
Reference in new issue
Block a user