mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 18:00:08 +00:00
* feat: Add return types to forum channel helpers. * fix: Use Discord-defined property names. Add `flags` property. * feat: Add return types to thread channel helpers. * feat: Add return types to channel helpers. * feat: Add return types to server discovery helpers. * misc!: Consistency: 'remove' -> 'delete'. * misc!: Add `get` keyword to function and file name. * feat: Add return types to emoji helpers. * misc!: Remove unused `bot` parameter. Capitalise 'URL'. * feat: Add return types to guild automod helpers. * feat: Add return types to guild scheduled event helpers. * misc!: Consistency: Rename `emojiURL` to `getEmojiURL`. * feat: Add return types to guild helpers. * misc!: Consistency: Add 'get' keyword to function and file names. * feat: Add return types to invite helpers. * feat: Add return types to integration helpers. * feat: Add return types to application command helpers. * feat: Add return types to followup message helpers. * feat: Add return types to interaction response helpers. * feat: Add return type to `createInvite()`. * feat: Add return types to member helpers. * misc!: Consistency: Add 'get' keyword to function and file names. * feat: Add return types to message helpers. * misc!: Consistency: 'remove' -> 'delete'. * fix: Use `slice()` to prevent unwanted side effects. * feat: Add return types to miscellaneous helpers. * misc!: Consistency: Add 'get' keyword to function and file names. * feat: Add return types to role helpers. * feat: Add return types to oauth helpers. * feat: Add return types to template helpers. * misc!: Consistency: Add 'guild' keyword to name. * feat: Add return types to voice helpers. * fix: Name function correctly. * feat: Add return types to webhook helpers. * misc!: Consistency: Rename `sendWebhook` to `sendWebhookMessage`. * misc: Update exports. * fix: Imports. * fix: Change return collection key type from `string` to `bigint`. Remove redundant code. * misc: Remove `undefined` from `runMethod()` return type. * style: Remove redundant types. * style: Rename endpoint call result variables to `result` and `results`. * misc: Reintroduce `bot` as first parameter. * misc: Adapt tests to changes made to helpers. * fix: Object being transformed twice. * style: Improve naming consistency of remaining files. * misc: `bigint` -> `number`. * style: Remove explicit `undefined` return. * style: Remove `void` operator in favour of generic type. * misc: Add missing `await` keyword. Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * style: Make `reason` property optional instead of `undefined`-able. * misc: Write out properties manually instead of using the spread operator. Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
import type { Bot } from "../../bot.ts";
|
|
import { Activity } from "../../transformers/activity.ts";
|
|
import { GatewayOpcodes, PresenceStatus } from "../../types/shared.ts";
|
|
|
|
export function editShardStatus(bot: Bot, shardId: number, data: StatusUpdate): Promise<void> {
|
|
const shard = bot.gateway.manager.shards.get(shardId);
|
|
if (!shard) {
|
|
throw new Error(`Shard (id: ${shardId}) not found.`);
|
|
}
|
|
|
|
return shard.send({
|
|
op: GatewayOpcodes.PresenceUpdate,
|
|
d: {
|
|
since: null,
|
|
afk: false,
|
|
activities: data.activities.map((activity) => ({
|
|
name: activity.name,
|
|
type: activity.type,
|
|
url: activity.url,
|
|
created_at: activity.createdAt,
|
|
timestamps: activity.startedAt || activity.endedAt
|
|
? {
|
|
start: activity.startedAt,
|
|
end: activity.endedAt,
|
|
}
|
|
: undefined,
|
|
application_id: activity.applicationId?.toString(),
|
|
details: activity.details,
|
|
state: activity.state,
|
|
emoji: activity.emoji
|
|
? {
|
|
name: activity.emoji.name,
|
|
id: activity.emoji.id?.toString(),
|
|
animated: activity.emoji.animated,
|
|
}
|
|
: undefined,
|
|
party: activity.partyId
|
|
? {
|
|
id: activity.partyId.toString(),
|
|
size: activity.partyMaxSize,
|
|
}
|
|
: undefined,
|
|
assets: activity.largeImage || activity.largeText || activity.smallImage || activity.smallText
|
|
? {
|
|
large_image: activity.largeImage,
|
|
large_text: activity.largeText,
|
|
small_image: activity.smallImage,
|
|
small_text: activity.smallText,
|
|
}
|
|
: undefined,
|
|
secrets: activity.join || activity.spectate || activity.match
|
|
? {
|
|
join: activity.join,
|
|
spectate: activity.spectate,
|
|
match: activity.match,
|
|
}
|
|
: undefined,
|
|
instance: activity.instance,
|
|
flags: activity.flags,
|
|
buttons: activity.buttons,
|
|
})),
|
|
status: data.status,
|
|
},
|
|
});
|
|
}
|
|
|
|
/** https://discord.com/developers/docs/topics/gateway#update-status */
|
|
export interface StatusUpdate {
|
|
// /** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */
|
|
// since: number | null;
|
|
/** The user's activities */
|
|
activities: Activity[];
|
|
/** The user's new status */
|
|
status: keyof typeof PresenceStatus;
|
|
// /** Whether or not the client is afk */
|
|
// afk: boolean;
|
|
}
|