Skip to content

Commit

Permalink
fix: Add error embeds to blacklist commands
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Nov 14, 2023
1 parent ff32f8e commit 69ba090
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
23 changes: 18 additions & 5 deletions src/commands/slash/Main/blacklist/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import db from '../../../../utils/Db.js';
import BlacklistCommand from './index.js';
import { stripIndents } from 'common-tags';
import { paginate } from '../../../../utils/Pagination.js';
import { colors } from '../../../../utils/Constants.js';
import { colors, emojis } from '../../../../utils/Constants.js';
import { errorEmbed } from '../../../../utils/Utils.js';

export default class ListBlacklists extends BlacklistCommand {
async execute(interaction: ChatInputCommandInteraction) {
Expand All @@ -22,7 +23,13 @@ export default class ListBlacklists extends BlacklistCommand {
});

if (!hubInDb) {
await interaction.editReply('Unknown hub. Make sure you are the owner or a moderator of the hub.');
await interaction.editReply({
embeds: [
errorEmbed(
`${emojis.no} Unknown hub. Make sure you are the owner or a moderator of the hub.`,
),
],
});
return;
}

Expand Down Expand Up @@ -55,7 +62,9 @@ export default class ListBlacklists extends BlacklistCommand {
name: data.serverName,
value: stripIndents`
**ServerId:** ${data.serverId}
**Moderator:** ${moderator ? `@${moderator.username} (${hubData?.moderatorId})` : 'Unknown'}
**Moderator:** ${
moderator ? `@${moderator.username} (${hubData?.moderatorId})` : 'Unknown'
}
**Reason:** ${hubData?.reason}
**Expires:** ${
!hubData?.expires ? 'Never.' : `<t:${Math.round(hubData.expires.getTime() / 1000)}:R>`
Expand Down Expand Up @@ -96,9 +105,13 @@ export default class ListBlacklists extends BlacklistCommand {
name: data.username,
value: stripIndents`
**UserID:** ${data.userId}
**Moderator:** ${moderator ? `@${moderator.username} (${hubData?.moderatorId})` : 'Unknown'}
**Moderator:** ${
moderator ? `@${moderator.username} (${hubData?.moderatorId})` : 'Unknown'
}
**Reason:** ${hubData?.reason}
**Expires:** ${!hubData?.expires ? 'Never.' : `<t:${Math.round(hubData.expires.getTime() / 1000)}:R>`}
**Expires:** ${
!hubData?.expires ? 'Never.' : `<t:${Math.round(hubData.expires.getTime() / 1000)}:R>`
}
`,
});

Expand Down
11 changes: 8 additions & 3 deletions src/commands/slash/Main/blacklist/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import BlacklistCommand from './index.js';
import BlacklistManager from '../../../../managers/BlacklistManager.js';
import parse from 'parse-duration';
import NetworkLogger from '../../../../structures/NetworkLogger.js';
import { errorEmbed } from '../../../../utils/Utils.js';

export default class UserBlacklist extends BlacklistCommand {
async execute(interaction: ChatInputCommandInteraction) {
Expand All @@ -25,9 +26,13 @@ export default class UserBlacklist extends BlacklistCommand {
});

if (!hubInDb) {
return await interaction.editReply(
`${emojis.no} Unknown hub. Make sure you are the owner or a moderator of the hub.`,
);
return await interaction.editReply({
embeds: [
errorEmbed(
`${emojis.no} Unknown hub. Make sure you are the owner or a moderator of the hub.`,
),
],
});
}

const blacklistManager = interaction.client.getBlacklistManager();
Expand Down
11 changes: 8 additions & 3 deletions src/commands/slash/Main/blacklist/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BlacklistManager from '../../../../managers/BlacklistManager.js';
import parse from 'parse-duration';
import { emojis } from '../../../../utils/Constants.js';
import NetworkLogger from '../../../../structures/NetworkLogger.js';
import { errorEmbed } from '../../../../utils/Utils.js';

export default class Server extends BlacklistCommand {
async execute(interaction: ChatInputCommandInteraction) {
Expand All @@ -23,9 +24,13 @@ export default class Server extends BlacklistCommand {
});

if (!hubInDb) {
return await interaction.editReply(
`${emojis.no} Unknown hub. Make sure you are the owner or a moderator of the hub.`,
);
return await interaction.editReply({
embeds: [
errorEmbed(
`${emojis.no} Unknown hub. Make sure you are the owner or a moderator of the hub.`,
),
],
});
}

const networkLogger = new NetworkLogger(hubInDb.id);
Expand Down

0 comments on commit 69ba090

Please sign in to comment.