1 |
import { BanOptions, CommandInteraction, Emoji, GuildChannel, GuildMember, Interaction, Message, TextChannel, User } from 'discord.js'; |
import { BanOptions, CommandInteraction, Emoji, GuildChannel, GuildMember, Interaction, Message, TextChannel, 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'; |
8 |
import getMember from '../../utils/getMember'; |
import getMember from '../../utils/getMember'; |
9 |
import History from '../../automod/History'; |
import History from '../../automod/History'; |
10 |
import { fetchEmoji } from '../../utils/Emoji'; |
import { fetchEmoji } from '../../utils/Emoji'; |
11 |
import { shouldNotModerate } from '../../utils/util'; |
import { hasPermission, shouldNotModerate } from '../../utils/util'; |
12 |
|
|
13 |
export default class ClearCommand extends BaseCommand { |
export default class ClearCommand extends BaseCommand { |
14 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
15 |
|
permissions = [Permissions.FLAGS.MANAGE_MESSAGES]; |
16 |
|
|
17 |
constructor() { |
constructor() { |
18 |
super('clear', 'moderation', []); |
super('clear', 'moderation', []); |
95 |
try { |
try { |
96 |
const member = await msg.guild?.members.fetch(user.id); |
const member = await msg.guild?.members.fetch(user.id); |
97 |
|
|
98 |
|
if (member && !(await hasPermission(client, member, msg, null, "You don't have permission to clear messages from this user."))) |
99 |
|
return; |
100 |
|
|
101 |
if (member && shouldNotModerate(client, member)) { |
if (member && shouldNotModerate(client, member)) { |
102 |
await msg.reply({ |
await msg.reply({ |
103 |
embeds: [ |
embeds: [ |
110 |
} |
} |
111 |
catch (e) { |
catch (e) { |
112 |
console.log(e); |
console.log(e); |
|
return; |
|
113 |
} |
} |
114 |
} |
} |
115 |
|
|