mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 00:40:07 +00:00
optionalize transformer (#2108)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordActivity } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformActivity(bot: Bot, payload: DiscordActivity) {
|
||||
return {
|
||||
@@ -35,4 +36,4 @@ export function transformActivity(bot: Bot, payload: DiscordActivity) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Activity extends ReturnType<typeof transformActivity> {}
|
||||
export interface Activity extends Optionalize<ReturnType<typeof transformActivity>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordApplication } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformApplication(bot: Bot, payload: DiscordApplication) {
|
||||
return {
|
||||
@@ -25,4 +26,4 @@ export function transformApplication(bot: Bot, payload: DiscordApplication) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Application extends ReturnType<typeof transformApplication> {}
|
||||
export interface Application extends Optionalize<ReturnType<typeof transformApplication>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordApplicationCommand } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformApplicationCommand(
|
||||
bot: Bot,
|
||||
@@ -19,4 +20,4 @@ export function transformApplicationCommand(
|
||||
};
|
||||
}
|
||||
|
||||
export interface ApplicationCommand extends ReturnType<typeof transformApplicationCommand> {}
|
||||
export interface ApplicationCommand extends Optionalize<ReturnType<typeof transformApplicationCommand>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordGuildApplicationCommandPermissions } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformApplicationCommandPermission(
|
||||
bot: Bot,
|
||||
@@ -17,4 +18,5 @@ export function transformApplicationCommandPermission(
|
||||
};
|
||||
}
|
||||
|
||||
export interface ApplicationCommandPermission extends ReturnType<typeof transformApplicationCommandPermission> {}
|
||||
export interface ApplicationCommandPermission
|
||||
extends Optionalize<ReturnType<typeof transformApplicationCommandPermission>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordAttachment } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformAttachment(bot: Bot, payload: DiscordAttachment) {
|
||||
return {
|
||||
@@ -15,4 +16,4 @@ export function transformAttachment(bot: Bot, payload: DiscordAttachment) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Attachment extends ReturnType<typeof transformAttachment> {}
|
||||
export interface Attachment extends Optionalize<ReturnType<typeof transformAttachment>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordAuditLogEntry } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformAuditlogEntry(
|
||||
bot: Bot,
|
||||
@@ -130,4 +131,4 @@ export function transformAuditlogEntry(
|
||||
};
|
||||
}
|
||||
|
||||
export interface AuditLogEntry extends ReturnType<typeof transformAuditlogEntry> {}
|
||||
export interface AuditLogEntry extends Optionalize<ReturnType<typeof transformAuditlogEntry>> {}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { Collection } from "../util/collection.ts";
|
||||
import { ChannelTypes } from "../types/shared.ts";
|
||||
import { DiscordChannel } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
const Mask = (1n << 64n) - 1n;
|
||||
|
||||
@@ -68,4 +67,4 @@ export function transformChannel(
|
||||
};
|
||||
}
|
||||
|
||||
export interface Channel extends ReturnType<typeof transformChannel> {}
|
||||
export interface Channel extends Optionalize<ReturnType<typeof transformChannel>> {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { ButtonStyles, MessageComponentTypes, TextStyles } from "../mod.ts";
|
||||
import { DiscordComponent, DiscordSelectOption } from "../types/discord.ts";
|
||||
import { DiscordComponent } from "../types/discord.ts";
|
||||
|
||||
export function transformComponent(bot: Bot, payload: DiscordComponent): Component {
|
||||
return {
|
||||
@@ -37,7 +37,6 @@ export function transformComponent(bot: Bot, payload: DiscordComponent): Compone
|
||||
};
|
||||
}
|
||||
|
||||
// export interface Component extends ReturnType<typeof transformComponent> {};
|
||||
// THIS TRANSFORMER HAS A CIRCULAR REFERENCE TO CALL ITSELF FOR COMPONENTS SO AN AUTOMATED TYPE CAN NOT BE CREATED!
|
||||
|
||||
export interface Component {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordEmoji } from "../types/discord.ts";
|
||||
import { EmojiToggles } from "./toggles/emoji.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformEmoji(bot: Bot, payload: DiscordEmoji) {
|
||||
return {
|
||||
@@ -12,4 +13,4 @@ export function transformEmoji(bot: Bot, payload: DiscordEmoji) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Emoji extends ReturnType<typeof transformEmoji> {}
|
||||
export interface Emoji extends Optionalize<ReturnType<typeof transformEmoji>> {}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DiscordGetGatewayBot } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformGatewayBot(payload: DiscordGetGatewayBot) {
|
||||
return {
|
||||
@@ -13,4 +14,4 @@ export function transformGatewayBot(payload: DiscordGetGatewayBot) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface GetGatewayBot extends ReturnType<typeof transformGatewayBot> {}
|
||||
export interface GetGatewayBot extends Optionalize<ReturnType<typeof transformGatewayBot>> {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { Collection } from "../util/collection.ts";
|
||||
import { DiscordGuild } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformGuild(
|
||||
bot: Bot,
|
||||
@@ -96,4 +97,4 @@ export function transformGuild(
|
||||
};
|
||||
}
|
||||
|
||||
export interface Guild extends ReturnType<typeof transformGuild> {}
|
||||
export interface Guild extends Optionalize<ReturnType<typeof transformGuild>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordIntegrationCreateUpdate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformIntegration(bot: Bot, payload: DiscordIntegrationCreateUpdate) {
|
||||
return {
|
||||
@@ -34,4 +35,4 @@ export function transformIntegration(bot: Bot, payload: DiscordIntegrationCreate
|
||||
};
|
||||
}
|
||||
|
||||
export interface Integration extends ReturnType<typeof transformIntegration> {}
|
||||
export interface Integration extends Optionalize<ReturnType<typeof transformIntegration>> {}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Attachment } from "./attachment.ts";
|
||||
import { Member, User } from "./member.ts";
|
||||
import { Message } from "./message.ts";
|
||||
import { Role } from "./role.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformInteraction(bot: Bot, payload: DiscordInteraction) {
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
|
||||
@@ -128,5 +129,5 @@ export function transformInteractionDataResolved(
|
||||
return transformed;
|
||||
}
|
||||
|
||||
export interface Interaction extends ReturnType<typeof transformInteraction> {}
|
||||
export interface InteractionDataResolved extends ReturnType<typeof transformInteractionDataResolved> {}
|
||||
export interface Interaction extends Optionalize<ReturnType<typeof transformInteraction>> {}
|
||||
export interface InteractionDataResolved extends Optionalize<ReturnType<typeof transformInteractionDataResolved>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordInviteCreate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformInvite(bot: Bot, invite: DiscordInviteCreate) {
|
||||
return {
|
||||
@@ -33,4 +34,4 @@ export function transformInvite(bot: Bot, invite: DiscordInviteCreate) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Invite extends ReturnType<typeof transformInvite> {}
|
||||
export interface Invite extends Optionalize<ReturnType<typeof transformInvite>> {}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Bot } from "../bot.ts";
|
||||
import { DiscordMember, DiscordUser } from "../types/discord.ts";
|
||||
import { MemberToggles } from "./toggles/member.ts";
|
||||
import { UserToggles } from "./toggles/user.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformUser(bot: Bot, payload: DiscordUser) {
|
||||
return {
|
||||
@@ -40,5 +41,5 @@ export function transformMember(
|
||||
};
|
||||
}
|
||||
|
||||
export interface Member extends ReturnType<typeof transformMember> {}
|
||||
export interface User extends ReturnType<typeof transformUser> {}
|
||||
export interface Member extends Optionalize<ReturnType<typeof transformMember>> {}
|
||||
export interface User extends Optionalize<ReturnType<typeof transformUser>> {}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Bot } from "../bot.ts";
|
||||
import { DiscordMessage } from "../types/discord.ts";
|
||||
import { CHANNEL_MENTION_REGEX } from "../util/constants.ts";
|
||||
import { MemberToggles } from "./toggles/member.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformMessage(bot: Bot, payload: DiscordMessage) {
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
|
||||
@@ -102,4 +103,4 @@ export function transformMessage(bot: Bot, payload: DiscordMessage) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Message extends ReturnType<typeof transformMessage> {}
|
||||
export interface Message extends Optionalize<ReturnType<typeof transformMessage>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordPresenceUpdate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export const statusTypes = {
|
||||
online: 0,
|
||||
@@ -21,5 +22,5 @@ export function transformPresence(bot: Bot, payload: DiscordPresenceUpdate) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface PresenceUpdate extends ReturnType<typeof transformPresence> {}
|
||||
export interface PresenceUpdate extends Optionalize<ReturnType<typeof transformPresence>> {}
|
||||
export type StatusTypes = keyof typeof statusTypes;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordRole } from "../types/discord.ts";
|
||||
import { RoleToggles } from "./toggles/role.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformRole(
|
||||
bot: Bot,
|
||||
@@ -26,4 +27,4 @@ export function transformRole(
|
||||
};
|
||||
}
|
||||
|
||||
export interface Role extends ReturnType<typeof transformRole> {}
|
||||
export interface Role extends Optionalize<ReturnType<typeof transformRole>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordScheduledEvent } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformScheduledEvent(
|
||||
bot: Bot,
|
||||
@@ -26,4 +27,4 @@ export function transformScheduledEvent(
|
||||
};
|
||||
}
|
||||
|
||||
export interface ScheduledEvent extends ReturnType<typeof transformScheduledEvent> {}
|
||||
export interface ScheduledEvent extends Optionalize<ReturnType<typeof transformScheduledEvent>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordStageInstance } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformStageInstance(
|
||||
bot: Bot,
|
||||
@@ -13,4 +14,4 @@ export function transformStageInstance(
|
||||
};
|
||||
}
|
||||
|
||||
export interface StageInstance extends ReturnType<typeof transformStageInstance> {}
|
||||
export interface StageInstance extends Optionalize<ReturnType<typeof transformStageInstance>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordSticker } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformSticker(bot: Bot, payload: DiscordSticker) {
|
||||
return {
|
||||
@@ -17,4 +18,4 @@ export function transformSticker(bot: Bot, payload: DiscordSticker) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Sticker extends ReturnType<typeof transformSticker> {}
|
||||
export interface Sticker extends Optionalize<ReturnType<typeof transformSticker>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordTeam } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformTeam(bot: Bot, payload: DiscordTeam) {
|
||||
const id = bot.transformers.snowflake(payload.id);
|
||||
@@ -19,4 +20,4 @@ export function transformTeam(bot: Bot, payload: DiscordTeam) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Team extends ReturnType<typeof transformTeam> {}
|
||||
export interface Team extends Optionalize<ReturnType<typeof transformTeam>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordThreadMember, DiscordThreadMemberGuildCreate } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformThreadMember(
|
||||
bot: Bot,
|
||||
@@ -21,5 +22,5 @@ export function transformThreadMemberGuildCreate(
|
||||
};
|
||||
}
|
||||
|
||||
export interface ThreadMember extends ReturnType<typeof transformThreadMember> {}
|
||||
export interface ThreadMemberGuildCreate extends ReturnType<typeof transformThreadMemberGuildCreate> {}
|
||||
export interface ThreadMember extends Optionalize<ReturnType<typeof transformThreadMember>> {}
|
||||
export interface ThreadMemberGuildCreate extends Optionalize<ReturnType<typeof transformThreadMemberGuildCreate>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordVoiceRegion } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformVoiceRegion(bot: Bot, payload: DiscordVoiceRegion) {
|
||||
return {
|
||||
@@ -11,4 +12,4 @@ export function transformVoiceRegion(bot: Bot, payload: DiscordVoiceRegion) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface VoiceRegions extends ReturnType<typeof transformVoiceRegion> {}
|
||||
export interface VoiceRegions extends Optionalize<ReturnType<typeof transformVoiceRegion>> {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordVoiceState } from "../types/discord.ts";
|
||||
import { VoiceStateToggles } from "./toggles/voice.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformVoiceState(
|
||||
bot: Bot,
|
||||
@@ -21,4 +22,4 @@ export function transformVoiceState(
|
||||
};
|
||||
}
|
||||
|
||||
export interface VoiceState extends ReturnType<typeof transformVoiceState> {}
|
||||
export interface VoiceState extends Optionalize<ReturnType<typeof transformVoiceState>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordWebhook } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformWebhook(bot: Bot, payload: DiscordWebhook) {
|
||||
return {
|
||||
@@ -31,4 +32,4 @@ export function transformWebhook(bot: Bot, payload: DiscordWebhook) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Webhook extends ReturnType<typeof transformWebhook> {}
|
||||
export interface Webhook extends Optionalize<ReturnType<typeof transformWebhook>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordWelcomeScreen } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformWelcomeScreen(
|
||||
bot: Bot,
|
||||
@@ -16,4 +17,4 @@ export function transformWelcomeScreen(
|
||||
};
|
||||
}
|
||||
|
||||
export interface WelcomeScreen extends ReturnType<typeof transformWelcomeScreen> {}
|
||||
export interface WelcomeScreen extends Optionalize<ReturnType<typeof transformWelcomeScreen>> {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordGuildWidget } from "../types/discord.ts";
|
||||
import { Optionalize } from "../types/shared.ts";
|
||||
|
||||
export function transformWidget(bot: Bot, payload: DiscordGuildWidget) {
|
||||
return {
|
||||
@@ -23,4 +24,4 @@ export function transformWidget(bot: Bot, payload: DiscordGuildWidget) {
|
||||
};
|
||||
}
|
||||
|
||||
export interface GuildWidget extends ReturnType<typeof transformWidget> {}
|
||||
export interface GuildWidget extends Optionalize<ReturnType<typeof transformWidget>> {}
|
||||
|
||||
Reference in New Issue
Block a user