6 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
import getUser from '../../utils/getUser'; |
import getUser from '../../utils/getUser'; |
8 |
import History from '../../automod/History'; |
import History from '../../automod/History'; |
9 |
|
import Punishment from '../../models/Punishment'; |
10 |
|
import PunishmentType from '../../types/PunishmentType'; |
11 |
|
import { shouldNotModerate } from '../../utils/util'; |
12 |
|
|
13 |
export default class BanCommand extends BaseCommand { |
export default class BanCommand extends BaseCommand { |
14 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
15 |
|
supportsContextMenu: boolean = true; |
16 |
|
|
17 |
constructor() { |
constructor() { |
18 |
super('ban', 'moderation', []); |
super('ban', 'moderation', ['Ban']); |
19 |
} |
} |
20 |
|
|
21 |
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
106 |
} |
} |
107 |
} |
} |
108 |
|
|
109 |
|
try { |
110 |
|
const member = await msg.guild?.members.fetch(user.id); |
111 |
|
|
112 |
|
if (member && shouldNotModerate(client, member)) { |
113 |
|
await msg.reply({ |
114 |
|
embeds: [ |
115 |
|
new MessageEmbed() |
116 |
|
.setColor('#f14a60') |
117 |
|
.setDescription('Cannot ban this user: Operation not permitted') |
118 |
|
] |
119 |
|
}); |
120 |
|
|
121 |
|
return; |
122 |
|
} |
123 |
|
} |
124 |
|
catch (e) { |
125 |
|
console.log(e); |
126 |
|
} |
127 |
|
|
128 |
try { |
try { |
129 |
await msg.guild?.bans.create(user, banOptions); |
await msg.guild?.bans.create(user, banOptions); |
130 |
|
|
131 |
|
await Punishment.create({ |
132 |
|
type: PunishmentType.BAN, |
133 |
|
user_id: user.id, |
134 |
|
guild_id: msg.guild!.id, |
135 |
|
mod_id: msg.member!.user.id, |
136 |
|
mod_tag: (msg.member!.user as User).tag, |
137 |
|
reason: banOptions.reason ?? undefined |
138 |
|
}); |
139 |
|
|
140 |
await History.create(user.id, msg.guild!, 'ban', msg.member!.user.id, typeof banOptions.reason === 'undefined' ? null : banOptions.reason, async (data: any) => undefined); |
await History.create(user.id, msg.guild!, 'ban', msg.member!.user.id, typeof banOptions.reason === 'undefined' ? null : banOptions.reason, async (data: any) => undefined); |
141 |
} |
} |
142 |
catch (e) { |
catch (e) { |
176 |
] |
] |
177 |
}); |
}); |
178 |
} |
} |
|
} |
|
179 |
|
} |