mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 14:06:07 +00:00
feat: Start shard with presence (#124)
* update presence on start * core impl
This commit is contained in:
parent
e4fa2a3ec3
commit
edef7989fe
@ -133,7 +133,12 @@ export type PickOptions = Pick<
|
|||||||
export interface BiscuitOptions {
|
export interface BiscuitOptions {
|
||||||
intents?: GatewayIntents;
|
intents?: GatewayIntents;
|
||||||
token: string;
|
token: string;
|
||||||
|
precense?: {
|
||||||
|
status: keyof typeof StatusTypes;
|
||||||
|
afk: boolean;
|
||||||
|
since: number | null;
|
||||||
|
activities: Activities[];
|
||||||
|
};
|
||||||
events?: {
|
events?: {
|
||||||
adapter?: { new (...args: any[]): EventAdapter };
|
adapter?: { new (...args: any[]): EventAdapter };
|
||||||
options: any;
|
options: any;
|
||||||
@ -244,6 +249,7 @@ export class Session {
|
|||||||
token: this.options.token,
|
token: this.options.token,
|
||||||
intents: this.options.intents,
|
intents: this.options.intents,
|
||||||
},
|
},
|
||||||
|
makePresence: this.options.precense
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +347,13 @@ export class Session {
|
|||||||
status: status.status,
|
status: status.status,
|
||||||
since: null,
|
since: null,
|
||||||
afk: false,
|
afk: false,
|
||||||
activities: status.activities.map(activity => {
|
activities: this.makePresenceActivites(status.activities),
|
||||||
|
},
|
||||||
|
}, prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
private makePresenceActivites(act: Activities[]): Record<string, unknown>[] {
|
||||||
|
return act.map(activity => {
|
||||||
return {
|
return {
|
||||||
name: activity.name,
|
name: activity.name,
|
||||||
type: activity.type,
|
type: activity.type,
|
||||||
@ -369,9 +381,7 @@ export class Session {
|
|||||||
flags: activity.flags,
|
flags: activity.flags,
|
||||||
buttons: activity.buttons,
|
buttons: activity.buttons,
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
},
|
|
||||||
}, prio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// END PRESENCE
|
// END PRESENCE
|
||||||
|
@ -102,6 +102,8 @@ export class ShardManager {
|
|||||||
|
|
||||||
config: this.options.config,
|
config: this.options.config,
|
||||||
|
|
||||||
|
presence: this.options.makePresence,
|
||||||
|
|
||||||
handlePayloads: async (shard, payload) => {
|
handlePayloads: async (shard, payload) => {
|
||||||
await this.options.handleDiscordPayload(shard, payload); // remove await?
|
await this.options.handleDiscordPayload(shard, payload); // remove await?
|
||||||
},
|
},
|
||||||
|
@ -118,6 +118,7 @@ export class Shard {
|
|||||||
},
|
},
|
||||||
intents: this.options.config.intents,
|
intents: this.options.config.intents,
|
||||||
shard: [this.options.id, this.options.gateway.shards],
|
shard: [this.options.id, this.options.gateway.shards],
|
||||||
|
presence: this.options.presence
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { DiscordGatewayPayload, DiscordGetGatewayBot, GatewayIntents } from '@biscuitland/api-types';
|
import type { DiscordGatewayPayload, DiscordGetGatewayBot, GatewayIntents, DiscordActivity } from '@biscuitland/api-types';
|
||||||
|
|
||||||
import type { ShardManager } from './services/shard-manager';
|
import type { ShardManager } from './services/shard-manager';
|
||||||
import type { Shard } from './services/shard';
|
import type { Shard } from './services/shard';
|
||||||
@ -23,6 +23,14 @@ export interface SMO {
|
|||||||
token: string;
|
token: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Presence on identify */
|
||||||
|
makePresence?: {
|
||||||
|
status: 'idle' | 'dnd' | 'online' | 'offline';
|
||||||
|
afk: boolean;
|
||||||
|
since: number | null;
|
||||||
|
activities: DiscordActivity[];
|
||||||
|
};
|
||||||
|
|
||||||
/** Options shards */
|
/** Options shards */
|
||||||
shards: ShardManagerShardsOptions;
|
shards: ShardManagerShardsOptions;
|
||||||
}
|
}
|
||||||
@ -81,6 +89,9 @@ export interface SO {
|
|||||||
token: string;
|
token: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Presence on identify */
|
||||||
|
presence?: ShardManagerOptions['makePresence'];
|
||||||
|
|
||||||
/** Function for interpretation of messages from discord */
|
/** Function for interpretation of messages from discord */
|
||||||
handlePayloads: (shard: Shard, data: DiscordGatewayPayload) => Promise<void>;
|
handlePayloads: (shard: Shard, data: DiscordGatewayPayload) => Promise<void>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user