diff options
| author | Zagrthos <[email protected]> | 2022-03-25 00:19:48 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-24 18:19:48 -0500 |
| commit | 2f9382f5171717fa512c03b3a3c08bd15ae85dd7 (patch) | |
| tree | d377ed5d0fbb68e682b22b064a4eac705e228475 /src/bot.ts | |
| parent | cf4905337005768644178d46c744cfdc90bef7ff (diff) | |
| download | muse-2f9382f5171717fa512c03b3a3c08bd15ae85dd7.tar.xz muse-2f9382f5171717fa512c03b3a3c08bd15ae85dd7.zip | |
Add customizable Bot status (#599)
Co-authored-by: Max Isom <[email protected]>
Co-authored-by: Max Isom <[email protected]>
Diffstat (limited to 'src/bot.ts')
| -rw-r--r-- | src/bot.ts | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,4 +1,4 @@ -import {Client, Collection, User} from 'discord.js'; +import {Client, Collection, ExcludeEnum, PresenceStatusData, User} from 'discord.js'; import {inject, injectable} from 'inversify'; import ora from 'ora'; import {TYPES} from './types.js'; @@ -15,10 +15,12 @@ import {generateDependencyReport} from '@discordjs/voice'; import {REST} from '@discordjs/rest'; import {Routes} from 'discord-api-types/v9'; import updatePermissionsForGuild from './utils/update-permissions-for-guild.js'; +import {ActivityTypes} from 'discord.js/typings/enums'; @injectable() export default class { private readonly client: Client; + private readonly config: Config; private readonly token: string; private readonly shouldRegisterCommandsOnBot: boolean; private readonly commandsByName!: Collection<string, Command>; @@ -29,6 +31,7 @@ export default class { @inject(TYPES.Config) config: Config, ) { this.client = client; + this.config = config; this.token = config.DISCORD_TOKEN; this.shouldRegisterCommandsOnBot = config.REGISTER_COMMANDS_ON_BOT; this.commandsByName = new Collection(); @@ -148,6 +151,17 @@ export default class { ); } + this.client.user!.setPresence({ + activities: [ + { + name: this.config.BOT_ACTIVITY, + type: this.config.BOT_ACTIVITY_TYPE as unknown as ExcludeEnum<typeof ActivityTypes, 'CUSTOM'>, + url: this.config.BOT_ACTIVITY_URL === '' ? undefined : this.config.BOT_ACTIVITY_URL, + }, + ], + status: this.config.BOT_STATUS as PresenceStatusData, + }); + // Update permissions spinner.text = '📡 updating permissions...'; await Promise.all(this.client.guilds.cache.map(async guild => updatePermissionsForGuild(guild))); |
