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'; |
7 |
import getUser from '../../utils/getUser'; |
import getUser from '../../utils/getUser'; |
|
import History from '../../automod/History'; |
|
8 |
import Punishment from '../../models/Punishment'; |
import Punishment from '../../models/Punishment'; |
9 |
import PunishmentType from '../../types/PunishmentType'; |
import PunishmentType from '../../types/PunishmentType'; |
10 |
import { fetchEmojiStr } from '../../utils/Emoji'; |
import { fetchEmojiStr } from '../../utils/Emoji'; |
11 |
|
import { hasPermission, shouldNotModerate } from '../../utils/util'; |
12 |
|
|
13 |
export default class SoftBanCommand extends BaseCommand { |
export default class SoftBanCommand extends BaseCommand { |
14 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
15 |
|
permissions = [Permissions.FLAGS.BAN_MEMBERS]; |
16 |
|
|
17 |
constructor() { |
constructor() { |
18 |
super('softban', 'moderation', []); |
super('softban', 'moderation', []); |
125 |
reply = <Message> await msg.fetchReply(); |
reply = <Message> await msg.fetchReply(); |
126 |
|
|
127 |
try { |
try { |
128 |
|
try { |
129 |
|
const member = await msg.guild!.members.fetch(user.id); |
130 |
|
|
131 |
|
if (member && !(await hasPermission(client, member, msg, null, "You don't have permission to softban this user."))) { |
132 |
|
return; |
133 |
|
} |
134 |
|
|
135 |
|
if (member && shouldNotModerate(client, member)) { |
136 |
|
await msg.reply({ |
137 |
|
embeds: [ |
138 |
|
new MessageEmbed() |
139 |
|
.setColor('#f14a60') |
140 |
|
.setDescription('This user cannot be softbanned.') |
141 |
|
] |
142 |
|
}); |
143 |
|
|
144 |
|
return; |
145 |
|
} |
146 |
|
} |
147 |
|
catch (e) { |
148 |
|
console.log(e); |
149 |
|
} |
150 |
|
|
151 |
await msg.guild?.bans.create(user, banOptions); |
await msg.guild?.bans.create(user, banOptions); |
152 |
await new Promise(r => setTimeout(r, 1600)); |
await new Promise(r => setTimeout(r, 1600)); |
153 |
await msg.guild?.bans.remove(user); |
await msg.guild?.bans.remove(user); |
161 |
reason: banOptions.reason ?? undefined, |
reason: banOptions.reason ?? undefined, |
162 |
meta: { |
meta: { |
163 |
days: banOptions.days |
days: banOptions.days |
164 |
} |
}, |
165 |
|
createdAt: new Date() |
166 |
}); |
}); |
167 |
|
|
168 |
await client.logger.logSoftBan(banOptions, msg.guild!, user, punishment); |
await client.logger.logSoftBan(banOptions, msg.guild!, user, punishment); |
201 |
return; |
return; |
202 |
} |
} |
203 |
} |
} |
|
} |
|
204 |
|
} |