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

Diff of /trunk/src/commands/moderation/TempBanCommand.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 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';
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 { fetchEmojiStr } from '../../utils/Emoji';  import { fetchEmojiStr } from '../../utils/Emoji';
11  import ms from 'ms';  import ms from 'ms';
12  import { clearTimeoutv2, getTimeouts, setTimeoutv2 } from '../../utils/setTimeout';  import { clearTimeoutv2, getTimeouts, setTimeoutv2 } from '../../utils/setTimeout';
13    import { hasPermission, shouldNotModerate } from '../../utils/util';
14    
15  export default class tempBanCommand extends BaseCommand {  export default class TempBanCommand extends BaseCommand {
16      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
17        permissions = [Permissions.FLAGS.BAN_MEMBERS];
18    
19      constructor() {      constructor() {
20          super('tempban', 'moderation', []);          super('tempban', 'moderation', []);
# Line 132  export default class tempBanCommand exte Line 133  export default class tempBanCommand exte
133          time = ms(time);          time = ms(time);
134            
135          try {          try {
136                try {
137                    const member = await msg.guild?.members.fetch(user.id);
138    
139                    if (member && !(await hasPermission(client, member, msg, null, "You don't have permission to tempban this user."))) {
140                        return;
141                    }
142    
143                    if (member && shouldNotModerate(client, member)) {
144                        await msg.reply({
145                            embeds: [
146                                new MessageEmbed()
147                                .setColor('#f14a60')
148                                .setDescription(`This user cannot be tempbanned.`)
149                            ]
150                        });
151    
152                        return;    
153                    }
154                }
155                catch (e) {
156                    console.log(e);
157                }
158            
159              await msg.guild?.bans.create(user, banOptions);              await msg.guild?.bans.create(user, banOptions);
160    
161              const punishment = await Punishment.create({              const punishment = await Punishment.create({
# Line 144  export default class tempBanCommand exte Line 168  export default class tempBanCommand exte
168                  meta: {                  meta: {
169                      days: banOptions.days,                      days: banOptions.days,
170                      time                      time
171                  }                  },
172                    createdAt: new Date()
173              });              });
174    
175              const timeouts = getTimeouts();              const timeouts = getTimeouts();
# Line 204  export default class tempBanCommand exte Line 229  export default class tempBanCommand exte
229              return;              return;
230          }          }
231      }      }
 }  
232    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26