mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
Add inviteCreate event
This commit is contained in:
parent
4f1cbcd9f3
commit
24ed499800
@ -31,6 +31,7 @@ import type {
|
||||
DiscordTypingStart,
|
||||
DiscordUser,
|
||||
DiscordWebhookUpdate,
|
||||
DiscordInviteCreate
|
||||
} from "../discordeno/mod.ts";
|
||||
|
||||
import type { Snowflake } from "./Snowflake.ts";
|
||||
@ -49,6 +50,7 @@ import User from "./structures/User.ts";
|
||||
import Integration from "./structures/Integration.ts";
|
||||
import Guild from "./structures/guilds/Guild.ts";
|
||||
import InteractionFactory from "./structures/interactions/InteractionFactory.ts";
|
||||
import { NewInviteCreate, InviteCreate } from "./structures/Invite.ts";
|
||||
|
||||
export type RawHandler<T> = (...args: [Session, number, T]) => void;
|
||||
export type Handler<T extends unknown[]> = (...args: T) => unknown;
|
||||
@ -275,6 +277,10 @@ export const MESSAGE_REACTION_REMOVE_EMOJI: RawHandler<DiscordMessageReactionRem
|
||||
session.emit("messageReactionRemoveEmoji", null);
|
||||
};
|
||||
|
||||
export const INVITE_CREATE: RawHandler<DiscordInviteCreate> = (session, _shardId, invite) => {
|
||||
session.emit("inviteCreate", NewInviteCreate(session, invite));
|
||||
}
|
||||
|
||||
export const raw: RawHandler<unknown> = (session, shardId, data) => {
|
||||
session.emit("raw", data, shardId);
|
||||
};
|
||||
@ -320,6 +326,7 @@ export interface Events {
|
||||
"integrationCreate": Handler<[Integration]>;
|
||||
"integrationUpdate": Handler<[Integration]>;
|
||||
"integrationDelete": Handler<[{ id: Snowflake, guildId?: Snowflake, applicationId?: Snowflake }]>;
|
||||
"inviteCreate": Handler<[InviteCreate]>;
|
||||
"autoModerationRuleCreate": Handler<[AutoModerationRule]>;
|
||||
"autoModerationRuleUpdate": Handler<[AutoModerationRule]>;
|
||||
"autoModerationRuleDelete": Handler<[AutoModerationRule]>;
|
||||
|
@ -8,7 +8,8 @@ import type {
|
||||
ScheduledEventEntityType,
|
||||
ScheduledEventPrivacyLevel,
|
||||
ScheduledEventStatus,
|
||||
DiscordApplication
|
||||
DiscordApplication,
|
||||
DiscordInviteCreate
|
||||
} from "../../discordeno/mod.ts";
|
||||
import { TargetTypes } from "../../discordeno/mod.ts";
|
||||
import { GuildChannel } from "./channels.ts";
|
||||
@ -48,6 +49,38 @@ export interface InviteScheduledEvent {
|
||||
image?: string;
|
||||
}
|
||||
|
||||
export interface InviteCreate {
|
||||
channelId: string;
|
||||
code: string;
|
||||
createdAt: string;
|
||||
guildId?: string;
|
||||
inviter?: User;
|
||||
maxAge: number;
|
||||
maxUses: number;
|
||||
targetType: TargetTypes;
|
||||
targetUser?: User;
|
||||
targetApplication?: Partial<Application>;
|
||||
temporary: boolean;
|
||||
uses: number;
|
||||
}
|
||||
|
||||
export function NewInviteCreate(session: Session, invite: DiscordInviteCreate): InviteCreate {
|
||||
return {
|
||||
channelId: invite.channel_id,
|
||||
code: invite.code,
|
||||
createdAt: invite.created_at,
|
||||
guildId: invite.guild_id,
|
||||
inviter: invite.inviter ? new User(session, invite.inviter) : undefined,
|
||||
maxAge: invite.max_age,
|
||||
maxUses: invite.max_uses,
|
||||
targetType: invite.target_type,
|
||||
targetUser: invite.target_user ? new User(session, invite.target_user) : undefined,
|
||||
targetApplication: invite.target_application ? new Application(session, invite.target_application as DiscordApplication) : undefined,
|
||||
temporary: invite.temporary,
|
||||
uses: invite.uses
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/resources/invite#invite-object
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user