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
|
import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib';
import { type ArgumentOptions, type Flag } from 'discord-akairo';
export default class EvidenceCommand extends BushCommand {
public constructor() {
super('evidence', {
aliases: ['evidence'],
category: 'moderation',
description: 'Add evidence to a modlog case.',
usage: ['evidence <caseId> <evidence>'],
examples: ['evidence IgQvFpzgIKJ77mZ62TEuG was spamming in #general'],
args: [
{
id: 'case_id',
description: 'The case to modify the evidence of.',
type: 'string',
prompt: 'What case would you like to modify the evidence of?',
slashType: 'STRING',
only: 'slash'
},
{
id: 'evidence',
description: 'The value to set the evidence to.',
type: 'string',
prompt: 'What would you like to modify the evidence to?',
slashType: 'STRING',
only: 'slash'
}
],
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
});
}
override *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
const case_id = yield {
id: 'case_id',
type: 'string',
prompt: {
start: 'What case would you like to modify the evidence of?',
retry: '{error} Pick a valid case to modify the evidence of.',
optional: false
}
};
const evidence = yield {
id: 'evidence',
type: 'string',
match: 'restContent',
prompt: {
start: 'What would you like to modify the evidence to?',
retry: '{error} Pick a valid argument.',
optional: !!message.attachments.some((attachment) => !!attachment.contentType?.includes('image'))
}
};
return { case_id, evidence };
}
public override async exec(
message: BushMessage | BushSlashMessage,
{ case_id: caseID, evidence }: { case_id: string; evidence?: string }
) {
const entry = await ModLog.findByPk(caseID);
if (!entry || entry.pseudo) return message.util.send(`${util.emojis.error} Invalid modlog entry.`);
if (entry.guild !== message.guild!.id) return message.util.reply(`${util.emojis.error} This modlog is from another server.`);
if (evidence && (message as BushMessage).attachments?.size)
return message.util.reply(`${util.emojis.error} Please either attach an image or a reason not both.`);
const _evidence = evidence ? evidence : !message.util.isSlash ? (message as BushMessage).attachments.first()?.url : undefined;
if (!_evidence) return message.util.reply(`${util.emojis.error} You must provide evidence for this modlog.`);
const oldEntry = entry.evidence;
entry.evidence = _evidence.trim();
await entry.save();
client.emit('bushUpdateModlog', message.member!, entry.id, 'evidence', oldEntry, entry.evidence);
return message.util.reply(`${util.emojis.success} Successfully updated the evidence for case \`${caseID}\`.`);
}
}
|