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

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

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

revision 86 by rakin, Mon Jul 29 17:28:32 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 { 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 { 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', []);
# Line 99  export default class MassBanCommand exte Line 100  export default class MassBanCommand exte
100                  try {                  try {
101                      console.log(banOptions.reason);                      console.log(banOptions.reason);
102    
103                        try {
104                            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)) {
110                                await msg.reply({
111                                    embeds: [
112                                        new MessageEmbed()
113                                        .setColor('#f14a60')
114                                        .setDescription('The user ' + user.tag + ' is not bannable.')
115                                    ]
116                                });
117    
118                                return;
119                            }
120                        }
121                        catch (e) {
122                            console.log(e);
123                        }
124    
125                      await Punishment.create({                      await Punishment.create({
126                          type: PunishmentType.BAN,                          type: PunishmentType.BAN,
127                          user_id: user.id,                          user_id: user.id,
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);
# Line 144  export default class MassBanCommand exte Line 168  export default class MassBanCommand exte
168              ]              ]
169          });          });
170      }      }
 }  
171    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26