1 |
import { unmute } from "../commands/moderation/UnmuteCommand"; |
2 |
import MuteRecord from "../models/MuteRecord"; |
3 |
import Queue from "../utils/structures/Queue"; |
4 |
|
5 |
export default class UnmuteQueue extends Queue { |
6 |
async execute({ memberID, guildID }: { [key: string]: string }): Promise<any> { |
7 |
const guild = this.client.guilds.cache.get(guildID); |
8 |
|
9 |
if (!guild) { |
10 |
return; |
11 |
} |
12 |
|
13 |
try { |
14 |
const member = await guild.members.fetch(memberID); |
15 |
|
16 |
if (member) { |
17 |
await unmute(this.client, member, this.client.user!); |
18 |
} |
19 |
else { |
20 |
throw new Error(); |
21 |
} |
22 |
} |
23 |
catch (e) { |
24 |
console.log(e); |
25 |
|
26 |
const muteRecord = await MuteRecord.findOne({ |
27 |
memberID, |
28 |
guildID |
29 |
}); |
30 |
|
31 |
if (muteRecord) { |
32 |
await muteRecord.delete(); |
33 |
} |
34 |
} |
35 |
|
36 |
// try { |
37 |
// const member = await guild.members.fetch(memberID); |
38 |
// console.log("Unmuting", member.user.tag); |
39 |
|
40 |
// await unmute(this.client, member, this.client.user!); |
41 |
// } |
42 |
// catch (e) { |
43 |
// console.log(e); |
44 |
// } |
45 |
} |
46 |
} |