Files
discordeno/transformers/invite.ts
Skillz4Killz a0a1554756 refactor: typings using ReturnType (#2105)
* fix: check new types idea

* fix: type errors

* fix: new style

* fix: more cleanup

* fix: more cleanup

* fix: cleanup audit logs

* fix: cleanup stickers

* fix: cleanup integrations

* fix: more cleanup

* fix: organize into 1 place

* fix: few errors

* fix: some broken import fixes

* fix: quite a lot of fixes across the board

* fix: more fixes for broken imports

* fix: more fixes for broken imports

* fix: handler imports

* fix: all remaining import errors

* fix: more errors needing fixes

* fix: clearing up transformers

* fix: few moer types

* fix: more cleanup of extra types

* fix: fmt

* fix: cleanup discordeno file

* Nuke Base Types (#2102)

* fix: cleanup snake stuff

* convert camelCase to snake_case (#2103)

* fix: add camelize

* fix: finalize remaining errors

* fix: imports in test

Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
2022-03-14 22:11:22 -04:00

37 lines
1.7 KiB
TypeScript

import { Bot } from "../bot.ts";
import { DiscordInviteCreate } from "../types/discord.ts";
export function transformInvite(bot: Bot, invite: DiscordInviteCreate) {
return {
/** The channel the invite is for */
channelId: bot.transformers.snowflake(invite.channel_id),
/** The unique invite code */
code: invite.code,
/** The time at which the invite was created */
createdAt: Date.parse(invite.created_at),
/** The guild of the invite */
guildId: invite.guild_id ? bot.transformers.snowflake(invite.guild_id) : undefined,
/** The user that created the invite */
inviter: invite.inviter ? bot.transformers.user(bot, invite.inviter) : undefined,
/** How long the invite is valid for (in seconds) */
maxAge: invite.max_age,
/** The maximum number of times the invite can be used */
maxUses: invite.max_uses,
/** The type of target for this voice channel invite */
targetType: invite.target_type,
/** The target user for this invite */
targetUser: invite.target_user ? bot.transformers.user(bot, invite.target_user) : undefined,
/** The embedded application to open for this voice channel embedded application invite */
targetApplication: invite.target_application
? // @ts-ignore should not break anything even though its partial. if it does blame wolf :)
bot.transformers.application(bot, invite.target_application)
: undefined,
/** Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) */
temporary: invite.temporary,
/** How many times the invite has been used (always will be 0) */
uses: invite.uses,
};
}
export interface Invite extends ReturnType<typeof transformInvite> {}