mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
PresenceUpdate (#45)
This commit is contained in:
parent
6ad22bb44d
commit
70a46eaefd
@ -25,6 +25,7 @@ import type {
|
|||||||
DiscordMessageReactionRemove,
|
DiscordMessageReactionRemove,
|
||||||
DiscordMessageReactionRemoveAll,
|
DiscordMessageReactionRemoveAll,
|
||||||
DiscordMessageReactionRemoveEmoji,
|
DiscordMessageReactionRemoveEmoji,
|
||||||
|
DiscordPresenceUpdate,
|
||||||
DiscordReady,
|
DiscordReady,
|
||||||
DiscordRole,
|
DiscordRole,
|
||||||
DiscordScheduledEvent,
|
DiscordScheduledEvent,
|
||||||
@ -47,6 +48,7 @@ import { AutoModerationExecution } from "./structures/AutoModerationExecution.ts
|
|||||||
import { type Channel, ChannelFactory, GuildChannel, ThreadChannel } from "./structures/channels.ts";
|
import { type Channel, ChannelFactory, GuildChannel, ThreadChannel } from "./structures/channels.ts";
|
||||||
import { type DiscordStageInstance, StageInstance } from "./structures/StageInstance.ts";
|
import { type DiscordStageInstance, StageInstance } from "./structures/StageInstance.ts";
|
||||||
import { ScheduledEvent } from "./structures/GuildScheduledEvent.ts";
|
import { ScheduledEvent } from "./structures/GuildScheduledEvent.ts";
|
||||||
|
import { Presence } from "./structures/Presence.ts";
|
||||||
|
|
||||||
import ThreadMember from "./structures/ThreadMember.ts";
|
import ThreadMember from "./structures/ThreadMember.ts";
|
||||||
import Member from "./structures/Member.ts";
|
import Member from "./structures/Member.ts";
|
||||||
@ -210,6 +212,10 @@ export const USER_UPDATE: RawHandler<DiscordUser> = (session, _shardId, payload)
|
|||||||
session.emit("userUpdate", new User(session, payload));
|
session.emit("userUpdate", new User(session, payload));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const PRESENCE_UPDATE: RawHandler<DiscordPresenceUpdate> = (session, _shardId, payload) => {
|
||||||
|
session.emit("presenceUpdate", new Presence(session, payload));
|
||||||
|
};
|
||||||
|
|
||||||
export const WEBHOOKS_UPDATE: RawHandler<DiscordWebhookUpdate> = (session, _shardId, webhook) => {
|
export const WEBHOOKS_UPDATE: RawHandler<DiscordWebhookUpdate> = (session, _shardId, webhook) => {
|
||||||
session.emit("webhooksUpdate", { guildId: webhook.guild_id, channelId: webhook.channel_id });
|
session.emit("webhooksUpdate", { guildId: webhook.guild_id, channelId: webhook.channel_id });
|
||||||
};
|
};
|
||||||
@ -400,4 +406,5 @@ export interface Events {
|
|||||||
"raw": Handler<[unknown, number]>;
|
"raw": Handler<[unknown, number]>;
|
||||||
"webhooksUpdate": Handler<[{ guildId: Snowflake, channelId: Snowflake }]>;
|
"webhooksUpdate": Handler<[{ guildId: Snowflake, channelId: Snowflake }]>;
|
||||||
"userUpdate": Handler<[User]>;
|
"userUpdate": Handler<[User]>;
|
||||||
|
"presenceUpdate": Handler<[Presence]>;
|
||||||
}
|
}
|
||||||
|
84
packages/biscuit/structures/Presence.ts
Normal file
84
packages/biscuit/structures/Presence.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import type {
|
||||||
|
ActivityTypes,
|
||||||
|
DiscordActivityButton,
|
||||||
|
DiscordActivitySecrets,
|
||||||
|
DiscordClientStatus,
|
||||||
|
DiscordPresenceUpdate,
|
||||||
|
} from "../../discordeno/mod.ts";
|
||||||
|
import type { Session } from "../Session.ts";
|
||||||
|
import { User } from "./User.ts";
|
||||||
|
import { Snowflake } from "../Snowflake.ts";
|
||||||
|
import type { ComponentEmoji } from "../Util.ts";
|
||||||
|
|
||||||
|
export interface ActivityAssets {
|
||||||
|
largeImage?: string;
|
||||||
|
largeText?: string;
|
||||||
|
smallImage?: string;
|
||||||
|
smallText?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Activities {
|
||||||
|
name: string;
|
||||||
|
type: ActivityTypes;
|
||||||
|
url?: string;
|
||||||
|
createdAt: number;
|
||||||
|
timestamps?: {
|
||||||
|
start?: number;
|
||||||
|
end?: number;
|
||||||
|
};
|
||||||
|
applicationId: Snowflake;
|
||||||
|
details?: string;
|
||||||
|
state?: string;
|
||||||
|
emoji?: ComponentEmoji;
|
||||||
|
party?: {
|
||||||
|
id?: string;
|
||||||
|
size?: number[];
|
||||||
|
};
|
||||||
|
assets?: ActivityAssets;
|
||||||
|
secrets?: DiscordActivitySecrets;
|
||||||
|
instance?: boolean;
|
||||||
|
flags?: number;
|
||||||
|
buttons?: DiscordActivityButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Presence {
|
||||||
|
constructor(session: Session, data: DiscordPresenceUpdate) {
|
||||||
|
this.session = session;
|
||||||
|
this.user = new User(this.session, data.user);
|
||||||
|
this.guildId = data.guild_id;
|
||||||
|
this.status = data.status;
|
||||||
|
this.activities = data.activities.map<Activities>((activity) =>
|
||||||
|
Object.create({
|
||||||
|
name: activity.name,
|
||||||
|
type: activity.type,
|
||||||
|
url: activity.url ? activity.url : undefined,
|
||||||
|
createdAt: activity.created_at,
|
||||||
|
timestamps: activity.timestamps,
|
||||||
|
applicationId: activity.application_id,
|
||||||
|
details: activity.details ? activity.details : undefined,
|
||||||
|
state: activity.state,
|
||||||
|
emoji: activity.emoji ? activity.emoji : undefined,
|
||||||
|
party: activity.party ? activity.party : undefined,
|
||||||
|
assets: activity.assets
|
||||||
|
? {
|
||||||
|
largeImage: activity.assets.large_image,
|
||||||
|
largeText: activity.assets.large_text,
|
||||||
|
smallImage: activity.assets.small_image,
|
||||||
|
smallText: activity.assets.small_text,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
secrets: activity.secrets ? activity.secrets : undefined,
|
||||||
|
instance: !!activity.instance,
|
||||||
|
flags: activity.flags,
|
||||||
|
buttons: activity.buttons,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
this.clientStatus = data.client_status;
|
||||||
|
}
|
||||||
|
session: Session;
|
||||||
|
user: User;
|
||||||
|
guildId: Snowflake;
|
||||||
|
status: string;
|
||||||
|
activities: Activities[];
|
||||||
|
clientStatus: DiscordClientStatus;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user