1 |
import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, User } from 'discord.js'; |
import { BanOptions, CommandInteraction, Message, User, Permissions } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
|
import getUser from '../../utils/getUser'; |
|
|
import History from '../../automod/History'; |
|
7 |
import { fetchEmoji } from '../../utils/Emoji'; |
import { fetchEmoji } from '../../utils/Emoji'; |
8 |
import Punishment from '../../models/Punishment'; |
import Punishment from '../../models/Punishment'; |
9 |
import PunishmentType from '../../types/PunishmentType'; |
import PunishmentType from '../../types/PunishmentType'; |
10 |
import { shouldNotModerate } from '../../utils/util'; |
import { hasPermission, shouldNotModerate } from '../../utils/util'; |
11 |
|
|
12 |
export default class MassBanCommand extends BaseCommand { |
export default class MassBanCommand extends BaseCommand { |
13 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
14 |
|
|
15 |
|
permissions = [Permissions.FLAGS.BAN_MEMBERS]; |
16 |
|
|
17 |
constructor() { |
constructor() { |
18 |
super('massban', 'moderation', []); |
super('massban', 'moderation', []); |
103 |
try { |
try { |
104 |
const member = await msg.guild?.members.fetch(user.id); |
const member = await msg.guild?.members.fetch(user.id); |
105 |
|
|
106 |
|
if (member && !(await hasPermission(client, member, msg, null, "You don't have permission to ban " + user.tag + "."))) |
107 |
|
break; |
108 |
|
|
109 |
if (member && shouldNotModerate(client, member)) { |
if (member && shouldNotModerate(client, member)) { |
110 |
await msg.reply({ |
await msg.reply({ |
111 |
embeds: [ |
embeds: [ |
120 |
} |
} |
121 |
catch (e) { |
catch (e) { |
122 |
console.log(e); |
console.log(e); |
|
continue; |
|
123 |
} |
} |
124 |
|
|
125 |
await Punishment.create({ |
await Punishment.create({ |
128 |
guild_id: msg.guild!.id, |
guild_id: msg.guild!.id, |
129 |
mod_id: msg.member!.user.id, |
mod_id: msg.member!.user.id, |
130 |
mod_tag: (msg.member!.user as User).tag, |
mod_tag: (msg.member!.user as User).tag, |
131 |
reason: banOptions.reason ?? undefined |
reason: banOptions.reason ?? undefined, |
132 |
|
createdAt: new Date() |
133 |
}); |
}); |
134 |
|
|
135 |
await msg.guild!.bans.create(user, banOptions); |
await msg.guild!.bans.create(user, banOptions); |