diff options
author | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-11 22:31:55 -0600 |
---|---|---|
committer | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-11 22:31:55 -0600 |
commit | 31764f52541a0566f148fb70c1a0e02c99bb5099 (patch) | |
tree | 1da5c2b17888fb8090e59a4fdef1b8a02705786c | |
parent | 42d8e605b497c98ed7a4b7e6f31fa1cc6d56e38a (diff) | |
download | tanzanite-31764f52541a0566f148fb70c1a0e02c99bb5099.tar.gz tanzanite-31764f52541a0566f148fb70c1a0e02c99bb5099.tar.bz2 tanzanite-31764f52541a0566f148fb70c1a0e02c99bb5099.zip |
add giveaway ping command and change '() => {}' to '() => undefined'
-rw-r--r-- | src/commands/moderation/role.ts | 4 | ||||
-rw-r--r-- | src/commands/moulberry-bush/giveawayping.ts | 68 | ||||
-rw-r--r-- | src/commands/moulberry-bush/rule.ts | 3 |
3 files changed, 71 insertions, 4 deletions
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 60fe369..e799698 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -155,7 +155,7 @@ export default class RoleCommand extends BotCommand { } // no checks if the user has MANAGE_ROLES if (action == 'remove') { - const success = await user.roles.remove(role.id).catch(() => {}); + const success = await user.roles.remove(role.id).catch(() => undefined); if (success) return message.util.reply( `<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`, @@ -167,7 +167,7 @@ export default class RoleCommand extends BotCommand { { allowedMentions: AllowedMentions.none() } ); } else if (action == 'add') { - const success = await user.roles.add(role.id).catch(() => {}); + const success = await user.roles.add(role.id).catch(() => undefined); if (success) { return message.util.reply( `<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`, diff --git a/src/commands/moulberry-bush/giveawayping.ts b/src/commands/moulberry-bush/giveawayping.ts new file mode 100644 index 0000000..e96b073 --- /dev/null +++ b/src/commands/moulberry-bush/giveawayping.ts @@ -0,0 +1,68 @@ +import { BotCommand } from '../../lib/extensions/BotCommand'; +import AllowedMentions from '../../lib/utils/AllowedMentions'; +import { Message, WebhookClient } from 'discord.js'; +import { TextChannel } from 'discord.js'; +import { NewsChannel } from 'discord.js'; + +export default class GiveawayPingCommand extends BotCommand { + constructor() { + super('giveawayping', { + aliases: ['giveawayping', 'giveawaypong'], + category: "Moulberry's Bush", + description: { + content: 'Pings the giveaway role.', + usage: 'giveawayping', + examples: ['giveawayping'] + }, + clientPermissions: ['MANAGE_MESSAGES'], + userPermissions: [ + 'SEND_MESSAGES', + 'MANAGE_GUILD', + 'MANAGE_MESSAGES', + 'BAN_MEMBERS', + 'KICK_MEMBERS', + 'VIEW_CHANNEL' + ], + channel: 'guild', + ignoreCooldown: [], + ignorePermissions: [], + cooldown: 1.44e7, //4 hours + ratelimit: 1, + editable: false + }); + } + public async exec(message: Message): Promise<unknown> { + if (message.guild.id !== '516977525906341928') + return message.reply( + "<:error:837123021016924261> This command may only be run in Moulberry's Bush." + ); + if ( + !['767782084981817344', '833855738501267456'].includes(message.channel.id) + ) + return message.reply( + '<:error:837123021016924261> This command may only be run in giveaway channels.' + ); + await message.delete().catch(() => undefined); + const webhooks = await (message.channel as + | TextChannel + | NewsChannel).fetchWebhooks(); + let webhookClient: WebhookClient; + if (webhooks.size < 1) { + const webhook = await (message.channel as + | TextChannel + | NewsChannel).createWebhook('Giveaway ping webhook'); + webhookClient = new WebhookClient(webhook.id, webhook.token); + } else { + const webhook = webhooks.first(); + webhookClient = new WebhookClient(webhook.id, webhook.token); + } + return webhookClient.send( + '🎉 <@&767782793261875210> Giveaway.\n\n<:mad:783046135392239626> Spamming, line breaking, gibberish etc. disqualifies you from winning. We can and will ban you from giveaways. Winners will all be checked and rerolled if needed.', + { + username: `${message.member.nickname || message.author.username}`, + avatarURL: message.author.avatarURL({ dynamic: true }), + allowedMentions: AllowedMentions.roles() + } + ); + } +} diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts index 3d1f549..4eac580 100644 --- a/src/commands/moulberry-bush/rule.ts +++ b/src/commands/moulberry-bush/rule.ts @@ -142,7 +142,6 @@ export default class RuleCommand extends BotCommand { allowedMentions: AllowedMentions.users() }); } - // eslint-disable-next-line @typescript-eslint/no-empty-function - await message.delete().catch(() => {}); + await message.delete().catch(() => undefined); } } |