/[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 71 by rakin, Mon Jul 29 17:28:28 2024 UTC revision 300 by rakin, Mon Jul 29 17:29:26 2024 UTC
# Line 1  Line 1 
1  import { ExcludeEnum, PresenceStatusData } from "discord.js";  import { ExcludeEnum, PresenceStatusData } from "discord.js";
2  import { ActivityTypes } from "discord.js/typings/enums";  import { ActivityTypes } from "discord.js/typings/enums";
3  import DiscordClient from "../client/Client";  import DiscordClient from "../client/Client";
4    import Service from "../utils/structures/Service";
5  import { random } from "../utils/util";  import { random } from "../utils/util";
6    
7  export default class RandomStatus {  export default class RandomStatus extends Service {
     constructor(protected client: DiscordClient) {  
           
     }  
   
8      async update(name?: string, type?: ExcludeEnum<typeof ActivityTypes, 'CUSTOM'>, status?: PresenceStatusData) {      async update(name?: string, type?: ExcludeEnum<typeof ActivityTypes, 'CUSTOM'>, 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 ?? 'WATCHING',              type: type ?? this.client.config.props.global.status.name ?? 'WATCHING',
14              name: name ?? 'over the server'              name: name ?? this.client.config.props.global.status.type ?? 'over the server'
15          });          });
16    
17            this.client.config.props.global.status = type || name ? {} : null;
18    
19            if (name) {
20                this.client.config.props.global.status.name = name;
21            }
22    
23            if (type) {
24                this.client.config.props.global.status.type = type;
25            }
26    
27          await this.client.user?.setStatus(status!);          await this.client.user?.setStatus(status!);
28            await this.client.config.write();
29      }      }
30  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26