/[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 159 by rakin, Mon Jul 29 17:28:49 2024 UTC revision 333 by rakin, Mon Jul 29 17:29:35 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: {              user_id: user.id,
35                  user_id: user.id,              guild_id: user.guild.id
                 guild_id: user.guild.id,  
             },  
             order: [  
                 ['id', 'DESC']  
             ]  
36          });          });
37    
38          if (hardmute) {          if (hardmute) {
39              for await (const roleID of hardmute.get().roles) {              for await (const roleID of hardmute.roles) {
40                  try {                  try {
41                      const role = await user.guild.roles.fetch(roleID);                      const role = await user.guild.roles.fetch(roleID);
42    
# Line 48  export async function unmute(client: Dis Line 49  export async function unmute(client: Dis
49                  }                  }
50              }              }
51    
52              await hardmute.destroy();              await hardmute.delete();
53          }          }
54    
55          const timeouts = getTimeouts();          const timeouts = getTimeouts();
# Line 78  export async function unmute(client: Dis Line 79  export async function unmute(client: Dis
79              mod_tag: d.tag,              mod_tag: d.tag,
80          });          });
81    
82            const muteRecord = await MuteRecord.findOne({
83                where: {
84                    user_id: user.user.id,
85                    guild_id: user.guild.id
86                }
87            });
88    
89            if (muteRecord) {
90                await muteRecord.destroy();
91            }
92    
93          try {          try {
94              await user.send({              await user.send({
95                  embeds: [                  embeds: [
# Line 102  export async function unmute(client: Dis Line 114  export async function unmute(client: Dis
114    
115  export default class UnmuteCommand extends BaseCommand {  export default class UnmuteCommand extends BaseCommand {
116      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
117        permissions = [Permissions.FLAGS.MODERATE_MEMBERS];
118    
119      constructor() {      constructor() {
120          super('unmute', 'moderation', []);          super('unmute', 'moderation', []);

Legend:
Removed from v.159  
changed lines
  Added in v.333

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26