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

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

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

revision 106 by rakin, Mon Jul 29 17:28:37 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 9  import History from '../../automod/Histo Line 9  import History from '../../automod/Histo
9  import Punishment from '../../models/Punishment';  import Punishment from '../../models/Punishment';
10  import PunishmentType from '../../types/PunishmentType';  import PunishmentType from '../../types/PunishmentType';
11  import { fetchEmojiStr } from '../../utils/Emoji';  import { fetchEmojiStr } from '../../utils/Emoji';
12    import { hasPermission, shouldNotModerate } from '../../utils/util';
13    
14  export default class SoftBanCommand extends BaseCommand {  export default class SoftBanCommand extends BaseCommand {
15      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
16        permissions = [Permissions.FLAGS.BAN_MEMBERS];
17    
18      constructor() {      constructor() {
19          super('softban', 'moderation', []);          super('softban', 'moderation', []);
# Line 124  export default class SoftBanCommand exte Line 126  export default class SoftBanCommand exte
126              reply = <Message> await msg.fetchReply();              reply = <Message> await msg.fetchReply();
127    
128          try {          try {
129                try {
130                    const member = await msg.guild!.members.fetch(user.id);
131    
132                    if (member && !(await hasPermission(client, member, msg, null, "You don't have permission to softban this user."))) {
133                        return;
134                    }
135    
136                    if (member && shouldNotModerate(client, member)) {
137                        await msg.reply({
138                            embeds: [
139                                new MessageEmbed()
140                                .setColor('#f14a60')
141                                .setDescription('This user cannot be softbanned.')
142                            ]
143                        });
144    
145                        return;
146                    }
147                }
148                catch (e) {
149                    console.log(e);
150                }
151                
152              await msg.guild?.bans.create(user, banOptions);              await msg.guild?.bans.create(user, banOptions);
153              await new Promise(r => setTimeout(r, 1600));              await new Promise(r => setTimeout(r, 1600));
154              await msg.guild?.bans.remove(user);              await msg.guild?.bans.remove(user);
# Line 176  export default class SoftBanCommand exte Line 201  export default class SoftBanCommand exte
201              return;              return;
202          }          }
203      }      }
 }  
204    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26