/[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 86 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 194 by rakin, Mon Jul 29 17:28:58 2024 UTC
# Line 8  import getUser from '../../utils/getUser Line 8  import getUser from '../../utils/getUser
8  import History from '../../automod/History';  import History from '../../automod/History';
9  import Punishment from '../../models/Punishment';  import Punishment from '../../models/Punishment';
10  import PunishmentType from '../../types/PunishmentType';  import PunishmentType from '../../types/PunishmentType';
11    import { shouldNotModerate, hasPermission } from '../../utils/util';
12    
13  export default class BanCommand extends BaseCommand {  export default class BanCommand extends BaseCommand {
14      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
15        supportsContextMenu: boolean = true;
16    
17      constructor() {      constructor() {
18          super('ban', 'moderation', []);          super('ban', 'moderation', ['Ban']);
19      }      }
20    
21      async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {      async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {
# Line 104  export default class BanCommand extends Line 106  export default class BanCommand extends
106              }              }
107          }          }
108    
109            try {
110                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)) {
117                    await msg.reply({
118                        embeds: [
119                            new MessageEmbed()
120                            .setColor('#f14a60')
121                            .setDescription('Cannot ban this user: Operation not permitted')    
122                        ]
123                    });
124                    
125                    return;
126                }
127            }
128            catch (e) {
129                console.log(e);
130            }
131            
132          try {          try {
133              await msg.guild?.bans.create(user, banOptions);              await msg.guild?.bans.create(user, banOptions);
134    
# Line 155  export default class BanCommand extends Line 180  export default class BanCommand extends
180              ]              ]
181          });          });
182      }      }
 }  
183    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26