aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moulberry-bush/report.ts
blob: 11ef269d851b3da0a3dc64f8032e15f4a96bd05a (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { Constants } from 'discord-akairo';
import { GuildMember, MessageEmbed, TextChannel } from 'discord.js';
import moment from 'moment';
import { AllowedMentions, BushCommand, BushMessage } from '../../lib';

export default class ReportCommand extends BushCommand {
	public constructor() {
		super('report', {
			aliases: ['report'],
			category: "Moulberry's Bush",
			description: {
				content: 'A command to report a user..',
				usage: 'report <user> <reason/evidence>',
				examples: ['report IRONM00N']
			},
			args: [
				{
					id: 'member',
					type: Constants.ArgumentTypes.MEMBER,
					match: Constants.ArgumentMatches.PHRASE,
					prompt: {
						start: 'Who would you like to report?',
						retry: `{error} Choose a valid user to report.`,
						optional: false
					}
				},
				{
					id: 'evidence',
					type: Constants.ArgumentTypes.STRING,
					match: Constants.ArgumentMatches.REST,
					prompt: {
						start: 'What evidence do you have?',
						retry: `{error} Provide what did they do wrong.`,
						optional: true
					}
				}
			],
			clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'],
			channel: 'guild',
			restrictedGuilds: ['516977525906341928'],
			slash: true,
			slashOptions: [
				{
					name: 'user',
					description: 'The user you would like to report.',
					type: 'USER',
					required: true
				},
				{
					name: 'evidence',
					description: 'What did the user do wrong?',
					type: 'STRING',
					required: false
				}
			],
			slashGuilds: ['516977525906341928']
		});
	}

	public async exec(message: BushMessage, { member, evidence }: { member: GuildMember; evidence: string }): Promise<unknown> {
		if (message.guild.id != this.client.consts.mappings.guilds.bush)
			return await message.util.reply(`${util.emojis.error} This command can only be run in Moulberry's bush.`);
		if (!member) return await message.util.reply(`${util.emojis.error} Choose someone to report`);
		if (member.user.id === '322862723090219008')
			return await message.util.reply({
				content: `Thank you for your report! We take these allegations very seriously and have reported <@${member.user.id}> to the FBI!`,
				allowedMentions: AllowedMentions.none()
			});
		if (member.user.bot)
			return await message.util.reply(`${util.emojis.error} You cannot report a bot <:WeirdChamp:756283321301860382>.`);

		//// if (!evidence) evidence = 'No Evidence.';
		//todo: Add channel id to db instead of hard coding it & allow in any guild
		//The formatting of the report is mostly copied from carl since it is pretty good when it actually works
		const reportEmbed = new MessageEmbed()
			.setFooter(`Reporter ID: ${message.author.id} Reported ID: ${member.user.id}`)
			.setTimestamp()
			.setAuthor(`Report From: ${message.author.tag}`, message.author.avatarURL({ dynamic: true }))
			.setTitle('New Report')
			.setColor(util.colors.red)
			.setDescription(evidence)
			.addField(
				'Reporter',
				`**Name:**${message.author.tag} <@${message.author.id}>\n**Joined:** ${moment(
					message.member.joinedTimestamp
				).fromNow()}\n**Created:** ${moment(message.author.createdTimestamp).fromNow()}\n**Sent From**: <#${
					message.channel.id
				}> [Jump to context](${message.url})`,
				true
			)
			.addField(
				'Reported User',
				`**Name:**${member.user.tag} <@${member.user.id}>\n**Joined:** ${moment(
					member.joinedTimestamp
				).fromNow()}\n**Created:** ${moment(member.user.createdTimestamp).fromNow()}`,
				true
			);

		//reusing code pog
		if (message.attachments.size > 0) {
			const fileName = message.attachments.first().name.toLowerCase();
			if (fileName.endsWith('.png') || fileName.endsWith('.jpg') || fileName.endsWith('.gif') || fileName.endsWith('.webp')) {
				reportEmbed.setImage(message.attachments.first().url);
			} else {
				reportEmbed.addField('Attachment', message.attachments.first().url);
			}
		}
		const reportChannel = <TextChannel>this.client.channels.cache.get('782972723654688848');
		await reportChannel.send({ embeds: [reportEmbed] }).then(async (ReportMessage) => {
			try {
				await ReportMessage.react(util.emojis.success);
				await ReportMessage.react(util.emojis.error);
			} catch {
				this.client.console.warn('ReportCommand', 'Could not react to report message.');
			}
		});
		return await message.util.reply('Successfully made a report.');
	}
}