mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +00:00
(transformers) return as Optionalize<typeof> (#2117)
* (transformers) return as Optionalize<typeof> * fix check error Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
co-authored by
Skillz4Killz
parent
2c7c36a53c
commit
8d4c0069b0
@@ -3,7 +3,7 @@ import { DiscordActivity } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformActivity(bot: Bot, payload: DiscordActivity) {
|
||||
return {
|
||||
const activity = {
|
||||
name: payload.name,
|
||||
type: payload.type,
|
||||
url: payload.url ?? undefined,
|
||||
@@ -34,6 +34,8 @@ export function transformActivity(bot: Bot, payload: DiscordActivity) {
|
||||
flags: payload.flags,
|
||||
buttons: payload.buttons,
|
||||
};
|
||||
|
||||
return activity as Optionalize<typeof activity>;
|
||||
}
|
||||
|
||||
export interface Activity extends Optionalize<ReturnType<typeof transformActivity>> {}
|
||||
export interface Activity extends ReturnType<typeof transformActivity> {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DiscordApplication } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformApplication(bot: Bot, payload: DiscordApplication) {
|
||||
return {
|
||||
const application = {
|
||||
name: payload.name,
|
||||
description: payload.description,
|
||||
rpcOrigins: payload.rpc_origins,
|
||||
@@ -24,6 +24,8 @@ export function transformApplication(bot: Bot, payload: DiscordApplication) {
|
||||
team: payload.team ? bot.transformers.team(bot, payload.team) : undefined,
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
};
|
||||
|
||||
return application as Optionalize<typeof application>;
|
||||
}
|
||||
|
||||
export interface Application extends Optionalize<ReturnType<typeof transformApplication>> {}
|
||||
export interface Application extends ReturnType<typeof transformApplication> {}
|
||||
|
||||
@@ -2,11 +2,8 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordApplicationCommand } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformApplicationCommand(
|
||||
bot: Bot,
|
||||
payload: DiscordApplicationCommand,
|
||||
) {
|
||||
return {
|
||||
export function transformApplicationCommand(bot: Bot, payload: DiscordApplicationCommand) {
|
||||
const applicationCommand = {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
applicationId: bot.transformers.snowflake(payload.application_id),
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
@@ -18,6 +15,8 @@ export function transformApplicationCommand(
|
||||
|
||||
options: payload.options?.map((option) => bot.transformers.applicationCommandOption(bot, option)),
|
||||
};
|
||||
|
||||
return applicationCommand as Optionalize<typeof applicationCommand>;
|
||||
}
|
||||
|
||||
export interface ApplicationCommand extends Optionalize<ReturnType<typeof transformApplicationCommand>> {}
|
||||
export interface ApplicationCommand extends ReturnType<typeof transformApplicationCommand> {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordApplicationCommandOption, DiscordApplicationCommandOptionChoice } from "../types/discord.ts";
|
||||
import { ApplicationCommandOptionTypes, ChannelTypes } from "../types/shared.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformApplicationCommandOption(
|
||||
bot: Bot,
|
||||
|
||||
@@ -2,11 +2,8 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordGuildApplicationCommandPermissions } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformApplicationCommandPermission(
|
||||
bot: Bot,
|
||||
payload: DiscordGuildApplicationCommandPermissions,
|
||||
) {
|
||||
return {
|
||||
export function transformApplicationCommandPermission(bot: Bot, payload: DiscordGuildApplicationCommandPermissions) {
|
||||
const applicationCommandPermission = {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
applicationId: bot.transformers.snowflake(payload.application_id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
@@ -16,7 +13,8 @@ export function transformApplicationCommandPermission(
|
||||
permission: perm.permission,
|
||||
})),
|
||||
};
|
||||
|
||||
return applicationCommandPermission as Optionalize<typeof applicationCommandPermission>;
|
||||
}
|
||||
|
||||
export interface ApplicationCommandPermission
|
||||
extends Optionalize<ReturnType<typeof transformApplicationCommandPermission>> {}
|
||||
export interface ApplicationCommandPermission extends ReturnType<typeof transformApplicationCommandPermission> {}
|
||||
|
||||
@@ -18,4 +18,4 @@ export function transformAttachment(bot: Bot, payload: DiscordAttachment) {
|
||||
return attachment as Optionalize<typeof attachment>;
|
||||
}
|
||||
|
||||
export interface Attachment extends Optionalize<ReturnType<typeof transformAttachment>> {}
|
||||
export interface Attachment extends ReturnType<typeof transformAttachment> {}
|
||||
|
||||
@@ -2,11 +2,8 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordAuditLogEntry } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformAuditlogEntry(
|
||||
bot: Bot,
|
||||
payload: DiscordAuditLogEntry,
|
||||
) {
|
||||
return {
|
||||
export function transformAuditlogEntry(bot: Bot, payload: DiscordAuditLogEntry) {
|
||||
const auditlogEntry = {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
// @ts-ignore TODO FIX THIS
|
||||
changes: payload.changes?.map((change) => {
|
||||
@@ -129,6 +126,8 @@ export function transformAuditlogEntry(
|
||||
: undefined,
|
||||
reason: payload.reason,
|
||||
};
|
||||
|
||||
return auditlogEntry as Optionalize<typeof auditlogEntry>;
|
||||
}
|
||||
|
||||
export interface AuditLogEntry extends Optionalize<ReturnType<typeof transformAuditlogEntry>> {}
|
||||
export interface AuditLogEntry extends ReturnType<typeof transformAuditlogEntry> {}
|
||||
|
||||
@@ -19,10 +19,7 @@ export function separateOverwrites(v: bigint) {
|
||||
return [Number(unpack64(v, 3)), unpack64(v, 2), unpack64(v, 0), unpack64(v, 1)] as [number, bigint, bigint, bigint];
|
||||
}
|
||||
|
||||
export function transformChannel(
|
||||
bot: Bot,
|
||||
payload: { channel: DiscordChannel } & { guildId?: bigint },
|
||||
) {
|
||||
export function transformChannel(bot: Bot, payload: { channel: DiscordChannel } & { guildId?: bigint }) {
|
||||
const channel = {
|
||||
// UNTRANSFORMED STUFF HERE
|
||||
type: payload.channel.type,
|
||||
@@ -69,4 +66,4 @@ export function transformChannel(
|
||||
return channel as Optionalize<typeof channel>;
|
||||
}
|
||||
|
||||
export interface Channel extends Optionalize<ReturnType<typeof transformChannel>> {}
|
||||
export interface Channel extends ReturnType<typeof transformChannel> {}
|
||||
|
||||
@@ -56,4 +56,4 @@ export function transformEmbed(bot: Bot, payload: DiscordEmbed) {
|
||||
return embed as Optionalize<typeof embed>;
|
||||
}
|
||||
|
||||
export interface Embed extends Optionalize<ReturnType<typeof transformEmbed>> {}
|
||||
export interface Embed extends ReturnType<typeof transformEmbed> {}
|
||||
|
||||
@@ -15,4 +15,4 @@ export function transformEmoji(bot: Bot, payload: DiscordEmoji) {
|
||||
return emoji as Optionalize<typeof emoji>;
|
||||
}
|
||||
|
||||
export interface Emoji extends Optionalize<ReturnType<typeof transformEmoji>> {}
|
||||
export interface Emoji extends ReturnType<typeof transformEmoji> {}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DiscordGetGatewayBot } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformGatewayBot(payload: DiscordGetGatewayBot) {
|
||||
return {
|
||||
const gatewayBot = {
|
||||
url: payload.url,
|
||||
shards: payload.shards,
|
||||
sessionStartLimit: {
|
||||
@@ -12,6 +12,8 @@ export function transformGatewayBot(payload: DiscordGetGatewayBot) {
|
||||
maxConcurrency: payload.session_start_limit.max_concurrency,
|
||||
},
|
||||
};
|
||||
|
||||
return gatewayBot as Optionalize<typeof gatewayBot>;
|
||||
}
|
||||
|
||||
export interface GetGatewayBot extends Optionalize<ReturnType<typeof transformGatewayBot>> {}
|
||||
export interface GetGatewayBot extends ReturnType<typeof transformGatewayBot> {}
|
||||
|
||||
@@ -5,13 +5,10 @@ import { DiscordGuild } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
import { GuildToggles } from "./toggles/guild.ts";
|
||||
|
||||
export function transformGuild(
|
||||
bot: Bot,
|
||||
payload: { guild: DiscordGuild } & { shardId: number },
|
||||
) {
|
||||
export function transformGuild(bot: Bot, payload: { guild: DiscordGuild } & { shardId: number }) {
|
||||
const guildId = bot.transformers.snowflake(payload.guild.id);
|
||||
|
||||
return {
|
||||
const guild = {
|
||||
afkTimeout: payload.guild.afk_timeout,
|
||||
approximateMemberCount: payload.guild.approximate_member_count,
|
||||
approximatePresenceCount: payload.guild.approximate_presence_count,
|
||||
@@ -103,6 +100,8 @@ export function transformGuild(
|
||||
: undefined,
|
||||
premiumProgressBarEnabled: payload.guild.premium_progress_bar_enabled,
|
||||
};
|
||||
|
||||
return guild as Optionalize<typeof guild>;
|
||||
}
|
||||
|
||||
export interface Guild extends Optionalize<ReturnType<typeof transformGuild>> {}
|
||||
export interface Guild extends ReturnType<typeof transformGuild> {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DiscordIntegrationCreateUpdate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformIntegration(bot: Bot, payload: DiscordIntegrationCreateUpdate) {
|
||||
return {
|
||||
const integration = {
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
name: payload.name,
|
||||
@@ -33,6 +33,8 @@ export function transformIntegration(bot: Bot, payload: DiscordIntegrationCreate
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
|
||||
return integration as Optionalize<typeof integration>;
|
||||
}
|
||||
|
||||
export interface Integration extends Optionalize<ReturnType<typeof transformIntegration>> {}
|
||||
export interface Integration extends ReturnType<typeof transformIntegration> {}
|
||||
|
||||
@@ -12,7 +12,7 @@ export function transformInteraction(bot: Bot, payload: DiscordInteraction) {
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
|
||||
const user = bot.transformers.user(bot, payload.member?.user || payload.user!);
|
||||
|
||||
return {
|
||||
const interaction = {
|
||||
// UNTRANSFORMED STUFF HERE
|
||||
type: payload.type,
|
||||
token: payload.token,
|
||||
@@ -47,13 +47,11 @@ export function transformInteraction(bot: Bot, payload: DiscordInteraction) {
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
|
||||
return interaction as Optionalize<typeof interaction>;
|
||||
}
|
||||
|
||||
export function transformInteractionDataResolved(
|
||||
bot: Bot,
|
||||
resolved: DiscordInteractionDataResolved,
|
||||
guildId?: bigint,
|
||||
) {
|
||||
export function transformInteractionDataResolved(bot: Bot, resolved: DiscordInteractionDataResolved, guildId?: bigint) {
|
||||
const transformed: {
|
||||
messages?: Collection<bigint, Message>;
|
||||
users?: Collection<bigint, User>;
|
||||
@@ -126,8 +124,8 @@ export function transformInteractionDataResolved(
|
||||
);
|
||||
}
|
||||
|
||||
return transformed;
|
||||
return transformed as Optionalize<typeof transformed>;
|
||||
}
|
||||
|
||||
export interface Interaction extends Optionalize<ReturnType<typeof transformInteraction>> {}
|
||||
export interface InteractionDataResolved extends Optionalize<ReturnType<typeof transformInteractionDataResolved>> {}
|
||||
export interface Interaction extends ReturnType<typeof transformInteraction> {}
|
||||
export interface InteractionDataResolved extends ReturnType<typeof transformInteractionDataResolved> {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DiscordInviteCreate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformInvite(bot: Bot, invite: DiscordInviteCreate) {
|
||||
return {
|
||||
const transformedInvite = {
|
||||
/** The channel the invite is for */
|
||||
channelId: bot.transformers.snowflake(invite.channel_id),
|
||||
/** The unique invite code */
|
||||
@@ -32,6 +32,8 @@ export function transformInvite(bot: Bot, invite: DiscordInviteCreate) {
|
||||
/** How many times the invite has been used (always will be 0) */
|
||||
uses: invite.uses,
|
||||
};
|
||||
|
||||
return transformedInvite as Optionalize<typeof transformedInvite>;
|
||||
}
|
||||
|
||||
export interface Invite extends Optionalize<ReturnType<typeof transformInvite>> {}
|
||||
export interface Invite extends ReturnType<typeof transformInvite> {}
|
||||
|
||||
@@ -21,12 +21,7 @@ export function transformUser(bot: Bot, payload: DiscordUser) {
|
||||
return user as Optionalize<typeof user>;
|
||||
}
|
||||
|
||||
export function transformMember(
|
||||
bot: Bot,
|
||||
payload: DiscordMember,
|
||||
guildId: bigint,
|
||||
userId: bigint,
|
||||
) {
|
||||
export function transformMember(bot: Bot, payload: DiscordMember, guildId: bigint, userId: bigint) {
|
||||
const member = {
|
||||
id: userId,
|
||||
guildId,
|
||||
@@ -45,5 +40,5 @@ export function transformMember(
|
||||
return member as Optionalize<typeof member>;
|
||||
}
|
||||
|
||||
export interface Member extends Optionalize<ReturnType<typeof transformMember>> {}
|
||||
export interface User extends Optionalize<ReturnType<typeof transformUser>> {}
|
||||
export interface Member extends ReturnType<typeof transformMember> {}
|
||||
export interface User extends ReturnType<typeof transformUser> {}
|
||||
|
||||
@@ -8,7 +8,7 @@ export function transformMessage(bot: Bot, payload: DiscordMessage) {
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
|
||||
const userId = bot.transformers.snowflake(payload.author.id);
|
||||
|
||||
return {
|
||||
const message = {
|
||||
// UNTRANSFORMED STUFF HERE
|
||||
content: payload.content || "",
|
||||
isBot: payload.author.bot || false,
|
||||
@@ -101,6 +101,8 @@ export function transformMessage(bot: Bot, payload: DiscordMessage) {
|
||||
],
|
||||
member: payload.member && guildId ? bot.transformers.member(bot, payload.member, guildId, userId) : undefined,
|
||||
};
|
||||
|
||||
return message as Optionalize<typeof message>;
|
||||
}
|
||||
|
||||
export interface Message extends Optionalize<ReturnType<typeof transformMessage>> {}
|
||||
export interface Message extends ReturnType<typeof transformMessage> {}
|
||||
|
||||
@@ -2,16 +2,16 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordPresenceUpdate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export const statusTypes = {
|
||||
export const statusTypes = Object.freeze({
|
||||
online: 0,
|
||||
dnd: 1,
|
||||
idle: 2,
|
||||
invisible: 3,
|
||||
offline: 4,
|
||||
} as const;
|
||||
});
|
||||
|
||||
export function transformPresence(bot: Bot, payload: DiscordPresenceUpdate) {
|
||||
return {
|
||||
const presence = {
|
||||
user: bot.transformers.user(bot, payload.user),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
status: statusTypes[payload.status],
|
||||
@@ -20,7 +20,9 @@ export function transformPresence(bot: Bot, payload: DiscordPresenceUpdate) {
|
||||
mobile: payload.client_status.mobile,
|
||||
web: payload.client_status.web,
|
||||
};
|
||||
|
||||
return presence as Optionalize<typeof presence>;
|
||||
}
|
||||
|
||||
export interface PresenceUpdate extends Optionalize<ReturnType<typeof transformPresence>> {}
|
||||
export interface PresenceUpdate extends ReturnType<typeof transformPresence> {}
|
||||
export type StatusTypes = keyof typeof statusTypes;
|
||||
|
||||
@@ -3,12 +3,7 @@ import { DiscordRole } from "../types/discord.ts";
|
||||
import { RoleToggles } from "./toggles/role.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformRole(
|
||||
bot: Bot,
|
||||
payload: { role: DiscordRole } & {
|
||||
guildId: bigint;
|
||||
},
|
||||
) {
|
||||
export function transformRole(bot: Bot, payload: { role: DiscordRole } & { guildId: bigint }) {
|
||||
const role = {
|
||||
name: payload.role.name,
|
||||
guildId: payload.guildId,
|
||||
@@ -29,4 +24,4 @@ export function transformRole(
|
||||
return role as Optionalize<typeof role>;
|
||||
}
|
||||
|
||||
export interface Role extends Optionalize<ReturnType<typeof transformRole>> {}
|
||||
export interface Role extends ReturnType<typeof transformRole> {}
|
||||
|
||||
@@ -6,7 +6,7 @@ export function transformScheduledEvent(
|
||||
bot: Bot,
|
||||
payload: DiscordScheduledEvent,
|
||||
) {
|
||||
return {
|
||||
const scheduledEvent = {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: payload.channel_id ? bot.transformers.snowflake(payload.channel_id) : undefined,
|
||||
@@ -25,6 +25,8 @@ export function transformScheduledEvent(
|
||||
location: payload.entity_metadata?.location,
|
||||
image: payload.image ? bot.utils.iconHashToBigInt(payload.image) : undefined,
|
||||
};
|
||||
|
||||
return scheduledEvent as Optionalize<typeof scheduledEvent>;
|
||||
}
|
||||
|
||||
export interface ScheduledEvent extends Optionalize<ReturnType<typeof transformScheduledEvent>> {}
|
||||
export interface ScheduledEvent extends ReturnType<typeof transformScheduledEvent> {}
|
||||
|
||||
@@ -2,11 +2,8 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordStageInstance } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformStageInstance(
|
||||
bot: Bot,
|
||||
payload: DiscordStageInstance,
|
||||
) {
|
||||
return {
|
||||
export function transformStageInstance(bot: Bot, payload: DiscordStageInstance) {
|
||||
const stageInstance = {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
@@ -15,6 +12,8 @@ export function transformStageInstance(
|
||||
? bot.transformers.snowflake(payload.guild_scheduled_event_id)
|
||||
: undefined,
|
||||
};
|
||||
|
||||
return stageInstance as Optionalize<typeof stageInstance>;
|
||||
}
|
||||
|
||||
export interface StageInstance extends Optionalize<ReturnType<typeof transformStageInstance>> {}
|
||||
export interface StageInstance extends ReturnType<typeof transformStageInstance> {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DiscordSticker } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformSticker(bot: Bot, payload: DiscordSticker) {
|
||||
return {
|
||||
const sticker = {
|
||||
id: bot.utils.snowflakeToBigint(payload.id),
|
||||
packId: payload.pack_id ? bot.utils.snowflakeToBigint(payload.pack_id) : undefined,
|
||||
name: payload.name,
|
||||
@@ -16,6 +16,8 @@ export function transformSticker(bot: Bot, payload: DiscordSticker) {
|
||||
user: payload.user ? bot.transformers.user(bot, payload.user) : undefined,
|
||||
sortValue: payload.sort_value,
|
||||
};
|
||||
|
||||
return sticker as Optionalize<typeof sticker>;
|
||||
}
|
||||
|
||||
export interface Sticker extends Optionalize<ReturnType<typeof transformSticker>> {}
|
||||
export interface Sticker extends ReturnType<typeof transformSticker> {}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Optionalize } from "../types/shared.ts";
|
||||
export function transformTeam(bot: Bot, payload: DiscordTeam) {
|
||||
const id = bot.transformers.snowflake(payload.id);
|
||||
|
||||
return {
|
||||
const team = {
|
||||
name: payload.name,
|
||||
|
||||
id,
|
||||
@@ -18,6 +18,8 @@ export function transformTeam(bot: Bot, payload: DiscordTeam) {
|
||||
user: bot.transformers.user(bot, member.user),
|
||||
})),
|
||||
};
|
||||
|
||||
return team as Optionalize<typeof team>;
|
||||
}
|
||||
|
||||
export interface Team extends Optionalize<ReturnType<typeof transformTeam>> {}
|
||||
export interface Team extends ReturnType<typeof transformTeam> {}
|
||||
|
||||
@@ -2,25 +2,23 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordThreadMember, DiscordThreadMemberGuildCreate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformThreadMember(
|
||||
bot: Bot,
|
||||
payload: DiscordThreadMember,
|
||||
) {
|
||||
return {
|
||||
export function transformThreadMember(bot: Bot, payload: DiscordThreadMember) {
|
||||
const threadMember = {
|
||||
id: payload.user_id ? bot.transformers.snowflake(payload.user_id) : undefined,
|
||||
threadId: payload.id ? bot.transformers.snowflake(payload.id) : undefined,
|
||||
joinTimestamp: Date.parse(payload.join_timestamp),
|
||||
};
|
||||
|
||||
return threadMember as Optionalize<typeof threadMember>;
|
||||
}
|
||||
|
||||
export function transformThreadMemberGuildCreate(
|
||||
bot: Bot,
|
||||
payload: DiscordThreadMemberGuildCreate,
|
||||
) {
|
||||
return {
|
||||
export function transformThreadMemberGuildCreate(bot: Bot, payload: DiscordThreadMemberGuildCreate) {
|
||||
const threadMember = {
|
||||
joinTimestamp: Date.parse(payload.join_timestamp),
|
||||
};
|
||||
|
||||
return threadMember as Optionalize<typeof threadMember>;
|
||||
}
|
||||
|
||||
export interface ThreadMember extends Optionalize<ReturnType<typeof transformThreadMember>> {}
|
||||
export interface ThreadMemberGuildCreate extends Optionalize<ReturnType<typeof transformThreadMemberGuildCreate>> {}
|
||||
export interface ThreadMember extends ReturnType<typeof transformThreadMember> {}
|
||||
export interface ThreadMemberGuildCreate extends ReturnType<typeof transformThreadMemberGuildCreate> {}
|
||||
|
||||
@@ -3,13 +3,15 @@ import { DiscordVoiceRegion } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformVoiceRegion(bot: Bot, payload: DiscordVoiceRegion) {
|
||||
return {
|
||||
const voiceRegion = {
|
||||
id: payload.id,
|
||||
name: payload.name,
|
||||
optimal: payload.optimal,
|
||||
deprecated: payload.deprecated,
|
||||
custom: payload.custom,
|
||||
};
|
||||
|
||||
return voiceRegion as Optionalize<typeof voiceRegion>;
|
||||
}
|
||||
|
||||
export interface VoiceRegions extends Optionalize<ReturnType<typeof transformVoiceRegion>> {}
|
||||
export interface VoiceRegions extends ReturnType<typeof transformVoiceRegion> {}
|
||||
|
||||
@@ -3,11 +3,8 @@ import { DiscordVoiceState } from "../types/discord.ts";
|
||||
import { VoiceStateToggles } from "./toggles/voice.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformVoiceState(
|
||||
bot: Bot,
|
||||
payload: { voiceState: DiscordVoiceState } & { guildId: bigint },
|
||||
) {
|
||||
return {
|
||||
export function transformVoiceState(bot: Bot, payload: { voiceState: DiscordVoiceState } & { guildId: bigint }) {
|
||||
const voiceState = {
|
||||
toggles: new VoiceStateToggles(payload.voiceState),
|
||||
|
||||
requestToSpeakTimestamp: payload.voiceState.request_to_speak_timestamp
|
||||
@@ -20,6 +17,8 @@ export function transformVoiceState(
|
||||
(payload.voiceState.guild_id ? bot.transformers.snowflake(payload.voiceState.guild_id) : 0n),
|
||||
userId: payload.voiceState.user_id ? bot.transformers.snowflake(payload.voiceState.user_id) : 0n,
|
||||
};
|
||||
|
||||
return voiceState as Optionalize<typeof voiceState>;
|
||||
}
|
||||
|
||||
export interface VoiceState extends Optionalize<ReturnType<typeof transformVoiceState>> {}
|
||||
export interface VoiceState extends ReturnType<typeof transformVoiceState> {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DiscordWebhook } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformWebhook(bot: Bot, payload: DiscordWebhook) {
|
||||
return {
|
||||
const webhook = {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
type: payload.type,
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
@@ -30,6 +30,8 @@ export function transformWebhook(bot: Bot, payload: DiscordWebhook) {
|
||||
/** The url used for executing the webhook (returned by the webhooks OAuth2 flow) */
|
||||
url: payload.url,
|
||||
};
|
||||
|
||||
return webhook as Optionalize<typeof webhook>;
|
||||
}
|
||||
|
||||
export interface Webhook extends Optionalize<ReturnType<typeof transformWebhook>> {}
|
||||
export interface Webhook extends ReturnType<typeof transformWebhook> {}
|
||||
|
||||
@@ -2,11 +2,8 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordWelcomeScreen } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformWelcomeScreen(
|
||||
bot: Bot,
|
||||
payload: DiscordWelcomeScreen,
|
||||
) {
|
||||
return {
|
||||
export function transformWelcomeScreen(bot: Bot, payload: DiscordWelcomeScreen) {
|
||||
const welcomeScreen = {
|
||||
description: payload.description ?? undefined,
|
||||
welcomeChannels: payload.welcome_channels.map((channel) => ({
|
||||
channelId: bot.transformers.snowflake(channel.channel_id),
|
||||
@@ -15,6 +12,8 @@ export function transformWelcomeScreen(
|
||||
emojiName: channel.emoji_name ?? undefined,
|
||||
})),
|
||||
};
|
||||
|
||||
return welcomeScreen as Optionalize<typeof welcomeScreen>;
|
||||
}
|
||||
|
||||
export interface WelcomeScreen extends Optionalize<ReturnType<typeof transformWelcomeScreen>> {}
|
||||
export interface WelcomeScreen extends ReturnType<typeof transformWelcomeScreen> {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DiscordGuildWidget } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformWidget(bot: Bot, payload: DiscordGuildWidget) {
|
||||
return {
|
||||
const widget = {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
name: payload.name,
|
||||
instant_invite: payload.instant_invite,
|
||||
@@ -22,6 +22,8 @@ export function transformWidget(bot: Bot, payload: DiscordGuildWidget) {
|
||||
})),
|
||||
presenceCount: payload.presence_count,
|
||||
};
|
||||
|
||||
return widget as Optionalize<typeof widget>;
|
||||
}
|
||||
|
||||
export interface GuildWidget extends Optionalize<ReturnType<typeof transformWidget>> {}
|
||||
export interface GuildWidget extends ReturnType<typeof transformWidget> {}
|
||||
|
||||
Reference in New Issue
Block a user