/[sudobot]/trunk/src/queues/unmute-job.ts
ViewVC logotype

Contents of /trunk/src/queues/unmute-job.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 335 - (show annotations)
Mon Jul 29 17:29:36 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1900 byte(s)
refactor(automute): use mongodb
1 import { TextChannel } from "discord.js";
2 import DiscordClient from "../client/Client";
3 import { unmute } from "../commands/moderation/UnmuteCommand";
4 import MuteRecord from "../models/MuteRecord";
5
6 export default async function unmuteJob(client: DiscordClient, guild_id: string, user_id: string) {
7 console.log('top-level');
8
9 const guild = await client.guilds.cache.get(guild_id);
10
11 console.log(guild_id, user_id);
12
13
14 // await client.db.get("SELECT * FROM unmutes WHERE time = ?", [new Date(dateTime!).toISOString()], async (err: any, data: any) => {
15 // if (err)
16 // console.log(err);
17
18 // if (data) {
19 // await client.db.get('DELETE FROM unmutes WHERE id = ?', [data.id], async (err: any) => {
20 // let guild = await client.guilds.cache.find(g => g.id === data.guild_id);
21 // let member = await guild?.members.cache.find(m => m.id === data.user_id);
22
23 // if (member) {
24 // await unmute(client, member, client.user!);
25 // await History.create(member.id, msg.guild!, 'unmute', client.user!.id, null);
26 // }
27
28 // console.log(data);
29 // });
30 // }
31 // });
32
33 if (guild) {
34 console.log('here');
35
36 try {
37 const member = await guild.members.fetch(user_id);
38
39 if (member) {
40 console.log('here2');
41
42 await unmute(client, member, client.user!);
43 }
44 else {
45 throw new Error();
46 }
47 }
48 catch (e) {
49 console.log(e);
50
51 const muteRecord = await MuteRecord.findOne({
52 user_id,
53 guild_id
54 });
55
56 if (muteRecord) {
57 await muteRecord.delete();
58 }
59 }
60 }
61 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26