mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +00:00
add member, message and fix guild toJSON
This commit is contained in:
@@ -63,7 +63,7 @@ export const guildToggles = {
|
||||
};
|
||||
|
||||
const baseGuild: Partial<DiscordenoGuild> = {
|
||||
get toJSON() {
|
||||
toJSON() {
|
||||
return {
|
||||
shardId: this.shardId!,
|
||||
id: this.id?.toString(),
|
||||
@@ -430,5 +430,5 @@ export interface DiscordenoGuild
|
||||
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */
|
||||
invites(): ReturnType<typeof getInvites>;
|
||||
/** Get the JSON version of the Guild object used to create this. Includes the shardId as well */
|
||||
toJSON: Guild & { shardId: number };
|
||||
toJSON(): Guild & { shardId: number };
|
||||
}
|
||||
|
||||
@@ -100,6 +100,32 @@ const baseMember: Partial<DiscordenoMember> = {
|
||||
get animatedAvatar() {
|
||||
return Boolean(this.bitfield! & memberToggles.animatedAvatar);
|
||||
},
|
||||
toJSON() {
|
||||
return (this.guilds?.map((g) => ({
|
||||
user: {
|
||||
id: this.id?.toString(),
|
||||
username: this.username,
|
||||
discriminator: this.discriminator?.toString(),
|
||||
avatar: this.avatar,
|
||||
bot: this.bot,
|
||||
system: this.system,
|
||||
mfaEnabled: this.mfaEnabled,
|
||||
locale: this.locale,
|
||||
verified: this.verified,
|
||||
email: this.email,
|
||||
flags: this.flags,
|
||||
premiumType: this.premiumType,
|
||||
publicFlags: this.publicFlags,
|
||||
},
|
||||
nick: g.nick,
|
||||
roles: g.roles.map((id) => id.toString()),
|
||||
joinedAt: g.joinedAt ? new Date(g.joinedAt).toISOString() : undefined,
|
||||
premiumSince: g.premiumSince,
|
||||
deaf: g.deaf,
|
||||
mute: g.mute,
|
||||
pending: g.pending,
|
||||
})) || []) as (GuildMemberWithUser & { guildId: string })[];
|
||||
},
|
||||
};
|
||||
|
||||
export async function createDiscordenoMember(
|
||||
@@ -220,4 +246,6 @@ export interface DiscordenoMember extends Omit<User, "discriminator" | "id"> {
|
||||
addRole(guildId: bigint, roleId: bigint, reason?: string): ReturnType<typeof addRole>;
|
||||
/** Remove a role from the member */
|
||||
removeRole(guildId: bigint, roleId: bigint, reason?: string): ReturnType<typeof removeRole>;
|
||||
/** Converts to a json object */
|
||||
toJSON(): (GuildMemberWithUser & { guildId: string })[];
|
||||
}
|
||||
|
||||
@@ -143,6 +143,54 @@ const baseMessage: Partial<DiscordenoMessage> = {
|
||||
get pinned() {
|
||||
return Boolean(this.bitfield! & messageToggles.pinned);
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
id: this.id?.toString(),
|
||||
channelId: this.channelId?.toString(),
|
||||
guildId: this.guildId?.toString(),
|
||||
author: {
|
||||
id: this.authorId?.toString(),
|
||||
username: this.tag?.substring(0, this.tag.length - 5),
|
||||
discriminator: this.tag?.substring(this.tag.length - 4),
|
||||
avatar: this.member?.avatar,
|
||||
bot: this.member?.bot,
|
||||
system: this.member?.system,
|
||||
mfaEnabled: this.member?.mfaEnabled,
|
||||
locale: this.member?.locale,
|
||||
verified: this.member?.verified,
|
||||
email: this.member?.email,
|
||||
flags: this.member?.flags,
|
||||
premiumType: this.member?.premiumType,
|
||||
publicFlags: this.member?.publicFlags,
|
||||
},
|
||||
member: this.member,
|
||||
content: this.content,
|
||||
timestamp: this.timestamp ? new Date(this.timestamp).toISOString() : undefined,
|
||||
editedTimestamp: this.editedTimestamp ? new Date(this.editedTimestamp).toISOString() : undefined,
|
||||
tts: this.tts,
|
||||
mentionEveryone: this.mentionEveryone,
|
||||
mentions: this.mentions,
|
||||
mentionRoles: this.mentionRoles,
|
||||
mentionChannels: this.mentionChannels,
|
||||
attachments: this.attachments,
|
||||
embeds: this.embeds,
|
||||
reactions: this.reactions,
|
||||
nonce: this.nonce,
|
||||
pinned: this.pinned,
|
||||
webhookId: this.webhookId,
|
||||
type: this.type,
|
||||
activity: this.activity,
|
||||
application: this.application,
|
||||
applicationId: this.applicationId,
|
||||
messageReference: this.messageReference,
|
||||
flags: this.flags,
|
||||
stickers: this.stickers,
|
||||
referencedMessage: this.referencedMessage,
|
||||
interaction: this.interaction,
|
||||
thread: this.thread,
|
||||
components: this.components,
|
||||
} as Message;
|
||||
}
|
||||
};
|
||||
|
||||
export async function createDiscordenoMessage(data: Message) {
|
||||
@@ -314,4 +362,6 @@ export interface DiscordenoMessage
|
||||
removeReactionEmoji(reaction: string): ReturnType<typeof removeReactionEmoji>;
|
||||
/** Removes a reaction from the given user on this message, defaults to bot */
|
||||
removeReaction(reaction: string, userId?: bigint): ReturnType<typeof removeReaction>;
|
||||
/** Convert to json */
|
||||
toJSON(): Message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user