Skip to content

Commit

Permalink
feat: allow setting custom status
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Apr 14, 2024
1 parent 45e7d2b commit 616c6a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions apps/bot/src/modules/sharding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export default class ShardingModule extends DexareModule<CraigBot> {
}
case 'setStatus': {
if (message.d.status === 'default') this.client.bot.editStatus('online', this.client.config.status);
else if (message.d.status === 'custom' && message.d.message)
// @ts-ignore
this.client.bot.editStatus({
type: 4,
name: 'craig',
state: message.d.message
});
else if (['online', 'idle', 'dnd'].includes(message.d.status) && message.d.message)
this.client.bot.editStatus(message.d.status, {
type: 0,
Expand Down
11 changes: 9 additions & 2 deletions apps/bot/src/textCommands/setstatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Eris from 'eris';
import ShardingModule from '../modules/sharding';
import TextCommand, { replyOrSend } from '../util';

type AllowedType = Eris.SelfStatus & 'default';
const ALLOWED_TYPES = ['online', 'idle', 'dnd', 'default'] as AllowedType[];
type AllowedType = Eris.SelfStatus & 'default' & 'custom';
const ALLOWED_TYPES = ['online', 'idle', 'dnd', 'default', 'custom'] as AllowedType[];

export default class SetStatusCommand extends TextCommand {
constructor(client: DexareClient<any>) {
Expand Down Expand Up @@ -33,6 +33,13 @@ export default class SetStatusCommand extends TextCommand {

if (sharding.on) sharding.send('setStatus', { status: ctx.args[0], message: ctx.args[1] });
else if (type === 'default') this.client.bot.editStatus('online', this.client.config.status);
else if (type === 'custom')
// @ts-ignore
this.client.bot.editStatus({
type: 4,
name: 'craig',
state: ctx.args[1]
});
else
this.client.bot.editStatus(type, {
type: 0,
Expand Down

0 comments on commit 616c6a3

Please sign in to comment.