/[sudobot]/trunk/src/utils/structures/Queue.ts
ViewVC logotype

Diff of /trunk/src/utils/structures/Queue.ts

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

revision 429 by rakin, Mon Jul 29 17:30:11 2024 UTC revision 430 by rakin, Mon Jul 29 17:30:12 2024 UTC
# Line 1  Line 1 
1  import DiscordClient from "../../client/Client";  import DiscordClient from "../../client/Client";
2  import { v4 as uuid } from 'uuid';  import { generate as randomstring } from 'randomstring';
3  import { IQueuedJob } from "../../models/QueuedJob";  import { IQueuedJob } from "../../models/QueuedJob";
4    
5  export interface QueueOptions {  export interface QueueOptions {
# Line 11  export interface QueueOptions { Line 11  export interface QueueOptions {
11    
12  export default abstract class Queue {  export default abstract class Queue {
13      protected completed = false;      protected completed = false;
14      protected runOn: number = 0;      public readonly runOn: number = 0;
15      public readonly id: string;      public readonly id: string;
16      protected readonly model: IQueuedJob;      public readonly model: IQueuedJob;
17      protected readonly timeout: NodeJS.Timeout;      protected readonly timeout: NodeJS.Timeout;
18        public readonly guild: string | undefined;
19    
20      constructor(protected client: DiscordClient, { runAfter, id, runAt, model }: QueueOptions) {      constructor(protected client: DiscordClient, { runAfter, id, runAt, model }: QueueOptions) {
21          if (runAfter !== 0 && runAfter !== 0 && !runAfter && !runAt) {          if (runAfter !== 0 && runAfter !== 0 && !runAfter && !runAt) {
# Line 22  export default abstract class Queue { Line 23  export default abstract class Queue {
23          }          }
24    
25          this.runOn = runAfter ? Date.now() + runAfter : runAt!.getTime();          this.runOn = runAfter ? Date.now() + runAfter : runAt!.getTime();
26          this.id = id ?? uuid();          this.id = id ?? randomstring(7);
27          this.model = model;          this.model = model;
28            this.guild = model.guild;
29    
30          const ms = this.runOn - Date.now();          const ms = this.runOn - Date.now();
31    

Legend:
Removed from v.429  
changed lines
  Added in v.430

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26