/[sudobot]/branches/2.x/src/automod/History.ts
ViewVC logotype

Contents of /branches/2.x/src/automod/History.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1356 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import { Guild } from "discord.js";
2 import DiscordClient from "../client/Client";
3
4 export default class History {
5 static get(user_id: string | number, guild: Guild, callback?: (data: any) => void) {
6 DiscordClient.client.db.all('SELECT * FROM history WHERE guild_id = ? AND user_id = ? ORDER BY id DESC', [guild.id, user_id], (err: any, data: any) => {
7 if (err) {
8 console.log(err);
9 }
10
11 callback !== undefined ? callback(data) : undefined;
12 });
13 }
14
15 static create(user_id: string | number, guild: Guild, type: string, mod: string | number, reason: string | null, callback?: (data: any) => void) {
16 DiscordClient.client.db.get('INSERT INTO history(type, user_id, guild_id, date, mod_id, reason) VALUES(?, ?, ?, ?, ?, ?)', [type, user_id, guild.id, new Date().toISOString(), mod, reason], (err: any) => {
17 if (err) {
18 console.log(err);
19 }
20
21 DiscordClient.client.db.get("SELECT * FROM history WHERE type = ? AND user_id = ? AND guild_id = ? ORDER BY id DESC LIMIT 0, 1", [type, user_id, guild.id], (err: any, data: any) => {
22 if (err) {
23 console.log(err);
24 }
25
26 callback !== undefined ? callback(data) : undefined;
27 });
28 });
29 }
30 };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26