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

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

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

revision 124 by rakin, Mon Jul 29 17:28:41 2024 UTC revision 235 by rakin, Mon Jul 29 17:29:08 2024 UTC
# Line 1  Line 1 
1  import { BanOptions, CommandInteraction, Guild, GuildMember, Interaction, Message, User } from 'discord.js';  import { BanOptions, CommandInteraction, Guild, 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 16  export async function unmute(client: Dis Line 16  export async function unmute(client: Dis
16          await History.create(user.id, user.guild!, 'unmute', d.id, null);          await History.create(user.id, user.guild!, 'unmute', d.id, null);
17    
18          const role = await user.guild!.roles.fetch(client.config.props[user.guild.id].mute_role);          const role = await user.guild!.roles.fetch(client.config.props[user.guild.id].mute_role);
19          await user.roles.remove(role!, 'Unmuting user');          try {
20                await user.roles.remove(role!, 'Unmuting user');
21            }
22            catch (e) {
23                console.log(e);
24            }
25    
26          const { default: Punishment } = await import('../../models/Punishment');          const { default: Punishment } = await import('../../models/Punishment');
27    
28          const { getTimeouts, clearTimeoutv2 } = await import('../../utils/setTimeout');          const { getTimeouts, clearTimeoutv2 } = await import('../../utils/setTimeout');
29    
30          const { default: Hardmute } = await import("../../models/Hardmute");          const { default: Hardmute } = await import("../../models/Hardmute");
31            const { default: MuteRecord } = await import("../../models/MuteRecord");
32    
33          const hardmute = await Hardmute.findOne({          const hardmute = await Hardmute.findOne({
34              where: {              where: {
# Line 78  export async function unmute(client: Dis Line 84  export async function unmute(client: Dis
84              mod_tag: d.tag,              mod_tag: d.tag,
85          });          });
86    
87          await user.send({          const muteRecord = await MuteRecord.findOne({
88              embeds: [              where: {
89                  new MessageEmbed()                  user_id: user.user.id,
90                  .setAuthor({                  guild_id: user.guild.id
91                      iconURL: <string> user.guild!.iconURL(),              }
                     name: `\tYou have been unmuted in ${user.guild!.name}`  
                 })  
             ]  
92          });          });
93    
94            if (muteRecord) {
95                await muteRecord.destroy();
96            }
97    
98            try {
99                await user.send({
100                    embeds: [
101                        new MessageEmbed()
102                        .setAuthor({
103                            iconURL: <string> user.guild!.iconURL(),
104                            name: `\tYou have been unmuted in ${user.guild!.name}`
105                        })
106                    ]
107                });
108            }
109            catch (e) {
110                console.log(e);
111            }
112    
113          await client.logger.logUnmute(user, d);          await client.logger.logUnmute(user, d);
114      }      }
115      catch (e) {      catch (e) {
# Line 97  export async function unmute(client: Dis Line 119  export async function unmute(client: Dis
119    
120  export default class UnmuteCommand extends BaseCommand {  export default class UnmuteCommand extends BaseCommand {
121      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
122        permissions = [Permissions.FLAGS.MODERATE_MEMBERS];
123    
124      constructor() {      constructor() {
125          super('unmute', 'moderation', []);          super('unmute', 'moderation', []);
# Line 179  export default class UnmuteCommand exten Line 202  export default class UnmuteCommand exten
202              ]              ]
203          });          });
204      }      }
 }  
205    }

Legend:
Removed from v.124  
changed lines
  Added in v.235

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26