aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moulberry-bush/giveawayPing.ts
blob: aebcc528217eafee2fbd0f4df6c37961483cccf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { AllowedMentions, BotCommand, clientSendAndPermCheck, emojis, mappings, type CommandMessage } from '#lib';
import assert from 'assert/strict';
import { PermissionFlagsBits } from 'discord.js';

export default class GiveawayPingCommand extends BotCommand {
	public constructor() {
		super('giveawayPing', {
			aliases: ['giveaway-ping', 'giveaway-pong'],
			category: "Moulberry's Bush",
			description: 'Pings the giveaway role.',
			usage: ['giveaway-ping'],
			examples: ['giveaway-ping'],
			clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageMessages], true),
			userPermissions: [
				PermissionFlagsBits.ManageGuild,
				PermissionFlagsBits.ManageMessages,
				PermissionFlagsBits.BanMembers,
				PermissionFlagsBits.KickMembers,
				PermissionFlagsBits.ViewChannel
			],
			channel: 'guild',
			ignoreCooldown: [],
			ignorePermissions: [],
			cooldown: 1.44e7, //4 hours
			ratelimit: 1,
			editable: false,
			restrictedGuilds: [mappings.guilds["Moulberry's Bush"]],
			restrictedChannels: [mappings.channels['giveaways']]
		});
	}

	public override async exec(message: CommandMessage) {
		assert(message.inGuild());

		if (!message.member!.permissions.has(PermissionFlagsBits.ManageGuild) && !message.member!.user.isOwner())
			await message.util.reply(`${emojis.error} You are missing the **ManageGuild** permission.`);

		await message.delete().catch(() => {});

		return await message.channel.send({
			content:
				'🎉 <@&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.',
			allowedMentions: AllowedMentions.roles()
		});

		//! Broken
		// const webhooks = await message.channel.fetchWebhooks();
		// let webhookClient: WebhookClient;
		// if (webhooks.size < 1) {
		// 	const webhook = await message.channel.createWebhook('Giveaway ping webhook');
		// 	webhookClient = new WebhookClient(webhook.id, webhook.token);
		// } else {
		// 	const webhook = webhooks.first();
		// 	webhookClient = new WebhookClient(webhook.id, webhook.token);
		// }
		// return await webhookClient.send({
		// 	content:
		// 		'🎉 <@&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(),
		// 	allowedMentions: AllowedMentions.roles()
		// });
	}
}