/[sudobot]/trunk/src/commands/moderation/BanCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/moderation/BanCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 153 by rakin, Mon Jul 29 17:28:48 2024 UTC revision 344 by rakin, Mon Jul 29 17:29:40 2024 UTC
# Line 1  Line 1 
1  import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, User } from 'discord.js';  import { Permissions, BanOptions, CommandInteraction, Message, User } 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 { shouldNotModerate } from '../../utils/util';  import { shouldNotModerate, hasPermission } from '../../utils/util';
11    
12  export default class BanCommand extends BaseCommand {  export default class BanCommand extends BaseCommand {
13      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
14      supportsContextMenu: boolean = true;      supportsContextMenu: boolean = true;
15        permissions = [Permissions.FLAGS.BAN_MEMBERS];
16    
17      constructor() {      constructor() {
18          super('ban', 'moderation', ['Ban']);          super('ban', 'moderation', ['Ban']);
# Line 109  export default class BanCommand extends Line 109  export default class BanCommand extends
109          try {          try {
110              const member = await msg.guild?.members.fetch(user.id);              const member = await msg.guild?.members.fetch(user.id);
111    
112                if (member && !(await hasPermission(client, member, msg, null, "You don't have permission to ban this user."))) {
113                    return;
114                }
115    
116              if (member && shouldNotModerate(client, member)) {              if (member && shouldNotModerate(client, member)) {
117                  await msg.reply({                  await msg.reply({
118                      embeds: [                      embeds: [
# Line 123  export default class BanCommand extends Line 127  export default class BanCommand extends
127          }          }
128          catch (e) {          catch (e) {
129              console.log(e);              console.log(e);
             return;  
130          }          }
131                    
132          try {          try {
# Line 135  export default class BanCommand extends Line 138  export default class BanCommand extends
138                  guild_id: msg.guild!.id,                  guild_id: msg.guild!.id,
139                  mod_id: msg.member!.user.id,                  mod_id: msg.member!.user.id,
140                  mod_tag: (msg.member!.user as User).tag,                  mod_tag: (msg.member!.user as User).tag,
141                  reason: banOptions.reason ?? undefined                  reason: banOptions.reason ?? undefined,
142                    createdAt: new Date()
143              });              });
144    
145              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);
146          }          }
147          catch (e) {          catch (e) {
148              await msg.reply({              await msg.reply({

Legend:
Removed from v.153  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26