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

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

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

revision 153 by rakin, Mon Jul 29 17:28:48 2024 UTC revision 336 by rakin, Mon Jul 29 17:29:36 2024 UTC
# Line 1  Line 1 
1  import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, User } from 'discord.js';  import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, Permissions, User } 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 10  import getMember from '../../utils/getMe Line 10  import getMember from '../../utils/getMe
10  import ms from 'ms';  import ms from 'ms';
11  import { unmute } from './UnmuteCommand';  import { unmute } from './UnmuteCommand';
12  import PunishmentType from '../../types/PunishmentType';  import PunishmentType from '../../types/PunishmentType';
13  import { shouldNotModerate } from '../../utils/util';  import { hasPermission, shouldNotModerate } from '../../utils/util';
14    
15  export async function mute(client: DiscordClient, dateTime: number | undefined, user: GuildMember, msg: Message | CommandInteraction, timeInterval: number | undefined, reason: string | undefined, hard: boolean = false) {  export async function mute(client: DiscordClient, dateTime: number | undefined, user: GuildMember, msg: Message | CommandInteraction, timeInterval: number | undefined, reason: string | undefined, hard: boolean = false) {
16      try {      try {
# Line 57  export async function mute(client: Disco Line 57  export async function mute(client: Disco
57                  user_id: user.id,                  user_id: user.id,
58                  roles: roles.map(role => role.id),                  roles: roles.map(role => role.id),
59                  guild_id: msg.guild!.id,                  guild_id: msg.guild!.id,
60                    createdAt: new Date()
61              });              });
62          }          }
63    
# Line 72  export async function mute(client: Disco Line 73  export async function mute(client: Disco
73              reason,              reason,
74              meta: {              meta: {
75                  time: timeInterval ? ms(timeInterval) : undefined                  time: timeInterval ? ms(timeInterval) : undefined
76              }              },
77                createdAt: new Date()
78          });          });
79                    
80          await client.logger.logMute(user, reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason, timeInterval, msg.member!.user as User, hard);          await client.logger.logMute(user, reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason, timeInterval, msg.member!.user as User, hard);
81          await user.send({  
82              embeds: [          try {
83                  new MessageEmbed()              await user.send({
84                  .setAuthor({                  embeds: [
85                      iconURL: <string> msg.guild!.iconURL(),                      new MessageEmbed()
86                      name: `\tYou have been muted in ${msg.guild!.name}`                      .setAuthor({
87                  })                          iconURL: <string> msg.guild!.iconURL(),
88                  .addField("Reason", reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason)                          name: `\tYou have been muted in ${msg.guild!.name}`
89              ]                      })
90          });                      .addField("Reason", reason === undefined || reason.trim() === '' ? "*No reason provided*" : reason)
91                    ]
92                });
93            }
94            catch (e) {
95                console.log(e);
96            }
97      }      }
98      catch (e) {      catch (e) {
99          console.log(e);          console.log(e);
# Line 113  export async function mute(client: Disco Line 121  export async function mute(client: Disco
121    
122  export default class MuteCommand extends BaseCommand {  export default class MuteCommand extends BaseCommand {
123      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
124        permissions = [Permissions.FLAGS.MODERATE_MEMBERS];
125    
126      constructor() {      constructor() {
127          super('mute', 'moderation', []);          super('mute', 'moderation', []);
# Line 234  export default class MuteCommand extends Line 243  export default class MuteCommand extends
243              dateTime = Date.now() + timeInterval;              dateTime = Date.now() + timeInterval;
244          }          }
245    
246            if (!(await hasPermission(client, user, msg, null, "You don't have permission to mute this user."))) {
247                return;
248            }
249            
250          if (shouldNotModerate(client, user)) {          if (shouldNotModerate(client, user)) {
251              await msg.reply({              await msg.reply({
252                  embeds: [                  embeds: [

Legend:
Removed from v.153  
changed lines
  Added in v.336

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26