MCPcopy Create free account
hub / github.com/RTByte/rtbyte / run

Method run

src/commands/Moderator/ban.js:22–60  ·  view source on GitHub ↗
(msg, [username, when = null, ...reason])

Source from the content-addressed store, hash-verified

20 }
21
22 async run(msg, [username, when = null, ...reason]) {
23 if (!Array.isArray(reason) || !reason.length) reason.unshift('Unspecified');
24 const silent = reason[0].endsWith('-s');
25 if (silent) reason[0].replace('-s', '');
26
27 if (username.id === msg.author.id) return msg.reject(msg.language.get('COMMAND_BAN_NO_BAN_SELF'));
28 if (username.id === this.client.user.id) return msg.reject(msg.language.get('COMMAND_BAN_NO_BAN_CLIENT'));
29 if (!msg.member.canMod(username)) return msg.reject(msg.language.get('COMMAND_BAN_NO_PERMS', username));
30
31 reason += ' (fc)';
32
33 const modCase = new ModCase(msg.guild)
34 .setUser(username)
35 .setType('ban')
36 .setReason(`${reason}`)
37 .setModerator(msg.author)
38 .setSilent(silent)
39 .setDuration(when);
40 await modCase.submit();
41
42 const embed = await modCase.embed();
43 await embed.send();
44
45 await msg.guild.members.ban(username, { days: 1, reason: when ? `${msg.language.get('GUILD_LOG_GUILDBANADD_TIMED', when)} | ${reason}` : reason });
46
47 if (when) {
48 await this.client.schedule.create('timedBan', when, {
49 data: {
50 guildID: msg.guild.id,
51 userID: username.id
52 },
53 catchUp: true
54 });
55 }
56
57 if (silent) return msg.delete({ reason: msg.language.get('COMMAND_MODERATION_SILENT') });
58
59 return msg.affirm();
60 }
61
62};

Callers 1

showMethod · 0.45

Calls 14

rejectMethod · 0.80
canModMethod · 0.80
setDurationMethod · 0.80
setSilentMethod · 0.80
setModeratorMethod · 0.80
setReasonMethod · 0.80
setTypeMethod · 0.80
setUserMethod · 0.80
submitMethod · 0.80
embedMethod · 0.80
sendMethod · 0.80
createMethod · 0.80

Tested by

no test coverage detected