/[sudobot]/trunk/src/services/RandomStatus.ts
ViewVC logotype

Diff of /trunk/src/services/RandomStatus.ts

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

revision 300 by rakin, Mon Jul 29 17:29:26 2024 UTC revision 301 by rakin, Mon Jul 29 17:29:26 2024 UTC
# Line 5  import Service from "../utils/structures Line 5  import Service from "../utils/structures
5  import { random } from "../utils/util";  import { random } from "../utils/util";
6    
7  export default class RandomStatus extends Service {  export default class RandomStatus extends Service {
8      async update(name?: string, type?: ExcludeEnum<typeof ActivityTypes, 'CUSTOM'>, status?: PresenceStatusData) {      async update(status?: PresenceStatusData) {
9          status ??= random(['dnd', 'idle', 'online'] as PresenceStatusData[]);          status ??= random(['dnd', 'idle', 'online'] as PresenceStatusData[]);
10          console.log(status);          console.log(status);
11                    
12          await this.client.user?.setActivity({          await this.client.user?.setActivity({
13              type: type ?? this.client.config.props.global.status.name ?? 'WATCHING',              type: this.client.config.props.status?.type ?? 'WATCHING',
14              name: name ?? this.client.config.props.global.status.type ?? 'over the server'              name: this.client.config.props.status?.name ?? 'over the server'
15          });          });
16    
         this.client.config.props.global.status = type || name ? {} : null;  
   
         if (name) {  
             this.client.config.props.global.status.name = name;  
         }  
   
         if (type) {  
             this.client.config.props.global.status.type = type;  
         }  
   
17          await this.client.user?.setStatus(status!);          await this.client.user?.setStatus(status!);
18          await this.client.config.write();      }
19    
20        async config(name?: string, type?: ExcludeEnum<typeof ActivityTypes, 'CUSTOM'>) {
21            this.client.config.props.status ??= {};
22            this.client.config.props.status.type = type ?? 'WATCHING';
23            this.client.config.props.status.name = name ?? 'over the server';
24            this.client.config.write();
25      }      }
26  }  }

Legend:
Removed from v.300  
changed lines
  Added in v.301

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26