Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: defer interaction for cache update #12

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Update <small>_ January 2024</small>

- fix: defer interaction for cache update (28/01/2024)
- fix: defer interaction on birthday list command (28/01/2024)
- fix: handle errors if message doesn't exist for delete logs (28/01/2024)
- fix: clearer logging for the role assignment handler (28/01/2024)
Expand Down
30 changes: 14 additions & 16 deletions src/commands/moderation/cacheUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const cacheUpdateEmbedField = (moderator: string, cacheType: string, cacheSize:
];

export default slashCommand(data, async ({ interaction }) => {
await interaction.deferReply({ ephemeral: true });

const modLogsChannel = interaction.guild.channels.resolve(constantsConfig.channels.MOD_LOGS) as TextChannel;
let cacheSize: number | undefined;
const start = new Date().getTime();
Expand All @@ -92,6 +94,17 @@ export default slashCommand(data, async ({ interaction }) => {
const duration = ((new Date().getTime() - start) / 1000).toFixed(2);

if (cacheSize !== undefined) {
await interaction.editReply({
embeds: [cacheUpdateEmbed(interaction.options.getSubcommand(),
cacheUpdateEmbedField(
interaction.user.tag,
interaction.options.getSubcommand(),
cacheSize.toString(),
duration,
),
Colors.Green)],
});

try {
await modLogsChannel.send({
embeds: [cacheUpdateEmbed(interaction.options.getSubcommand(),
Expand All @@ -104,22 +117,7 @@ export default slashCommand(data, async ({ interaction }) => {
Colors.Green)],
});
} catch (error) {
await interaction.reply({
embeds: [noChannelEmbed(interaction.options.getSubcommand(), 'mod-log')],
ephemeral: true,
});
await interaction.followUp({ embeds: [noChannelEmbed(interaction.options.getSubcommand(), 'mod-log')] });
}

await interaction.reply({
embeds: [cacheUpdateEmbed(interaction.options.getSubcommand(),
cacheUpdateEmbedField(
interaction.user.tag,
interaction.options.getSubcommand(),
cacheSize.toString(),
duration,
),
Colors.Green)],
ephemeral: true,
});
}
});
Loading