/[sudobot]/trunk/src/utils/setTimeout.ts
ViewVC logotype

Diff of /trunk/src/utils/setTimeout.ts

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

revision 51 by rakin, Mon Jul 29 17:28:23 2024 UTC revision 59 by rakin, Mon Jul 29 17:28:25 2024 UTC
# Line 1  Line 1 
1  import path from "path";  import path from "path";
2  import DiscordClient from "../client/Client";  import DiscordClient from "../client/Client";
3    import Timeout from "../models/Timeout";
4    
5  const timeouts = new Map();  const timeouts = new Map();
6    
7  export const runTimeouts = async () => {  export const runTimeouts = async () => {
8      const data = await DiscordClient.client.db.allAsync("SELECT * FROM timeouts");      const data = (await Timeout.findAll());
9    
10      // await console.log(data);      // await console.log(data);
11    
# Line 15  export const runTimeouts = async () => { Line 16  export const runTimeouts = async () => {
16    
17              let timeout = await setTimeout(async () => {              let timeout = await setTimeout(async () => {
18                  await console.log('TIMEOUT');                  await console.log('TIMEOUT');
19                  await DiscordClient.client.db.runAsync("DELETE FROM timeouts WHERE id = ?", [row.id]);                  await DiscordClient.client.db.runAsync("DELETE FROM timeouts WHERE id = ?", [row.get('id')]);
20                  await timeouts.delete(row.id);                  await timeouts.delete(row.get('id'));
21                  (await import(row.filePath)).default(DiscordClient.client, ...JSON.parse(row.params));                  (await import(row.get('filePath') as string)).default(DiscordClient.client, ...JSON.parse(row.get('params') as string));
22              }, new Date(row.time).getTime() - Date.now());              }, new Date(row.get('time') as string).getTime() - Date.now());
23    
24              await timeouts.set(row.id, {              await timeouts.set(row.get('id'), {
25                  row,                  row,
26                  timeout                  timeout
27              });              });

Legend:
Removed from v.51  
changed lines
  Added in v.59

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26