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

Legend:
Removed from v.226  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26