/[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 61 by rakin, Mon Jul 29 17:28:26 2024 UTC revision 205 by rakin, Mon Jul 29 17:29:00 2024 UTC
# Line 1  Line 1 
1  import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, User } from 'discord.js';  import { BanOptions, CommandInteraction, GuildMember, Interaction, 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';
# Line 7  import MessageEmbed from '../../client/M Line 7  import MessageEmbed from '../../client/M
7  import getUser from '../../utils/getUser';  import getUser from '../../utils/getUser';
8  import History from '../../automod/History';  import History from '../../automod/History';
9  import { fetchEmoji } from '../../utils/Emoji';  import { fetchEmoji } from '../../utils/Emoji';
10    import Punishment from '../../models/Punishment';
11    import PunishmentType from '../../types/PunishmentType';
12    import { hasPermission, shouldNotModerate } from '../../utils/util';
13    
14  export default class MassBanCommand extends BaseCommand {  export default class MassBanCommand extends BaseCommand {
15      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
16        
17        permissions = [Permissions.FLAGS.BAN_MEMBERS];
18    
19      constructor() {      constructor() {
20          super('massban', 'moderation', []);          super('massban', 'moderation', []);
# Line 96  export default class MassBanCommand exte Line 101  export default class MassBanCommand exte
101    
102                  try {                  try {
103                      console.log(banOptions.reason);                      console.log(banOptions.reason);
104    
105                        try {
106                            const member = await msg.guild?.members.fetch(user.id);
107    
108                            if (member && !(await hasPermission(client, member, msg, null, "You don't have permission to ban " + user.tag + ".")))
109                                break;
110                                
111                            if (member && shouldNotModerate(client, member)) {
112                                await msg.reply({
113                                    embeds: [
114                                        new MessageEmbed()
115                                        .setColor('#f14a60')
116                                        .setDescription('The user ' + user.tag + ' is not bannable.')
117                                    ]
118                                });
119    
120                                return;
121                            }
122                        }
123                        catch (e) {
124                            console.log(e);
125                        }
126    
127                        await Punishment.create({
128                            type: PunishmentType.BAN,
129                            user_id: user.id,
130                            guild_id: msg.guild!.id,
131                            mod_id: msg.member!.user.id,
132                            mod_tag: (msg.member!.user as User).tag,
133                            reason: banOptions.reason ?? undefined
134                        });
135    
136                      await msg.guild!.bans.create(user, banOptions);                      await msg.guild!.bans.create(user, banOptions);
137                                            
138                      usersStr += user.tag + ' (' + user.id + ')\n';                      usersStr += user.tag + ' (' + user.id + ')\n';
# Line 132  export default class MassBanCommand exte Line 169  export default class MassBanCommand exte
169              ]              ]
170          });          });
171      }      }
 }  
172    }

Legend:
Removed from v.61  
changed lines
  Added in v.205

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26