mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
working on interactions
This commit is contained in:
parent
b4d5c236d8
commit
b87c0716cc
41
structures/Component.ts
Normal file
41
structures/Component.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { DiscordComponent, MessageComponentTypes } from "../vendor/external.ts";
|
||||
import Emoji from "./Emoji.ts";
|
||||
|
||||
export class Component {
|
||||
constructor(session: Session, data: DiscordComponent) {
|
||||
this.session = session;
|
||||
this.customId = data.custom_id;
|
||||
this.type = data.type
|
||||
this.components = data.components?.map((component) => new Component(session, component));
|
||||
this.disabled = !!data.disabled;
|
||||
|
||||
if (data.emoji) {
|
||||
this.emoji = new Emoji(session, data.emoji);
|
||||
}
|
||||
|
||||
this.maxValues = data.max_values;
|
||||
this.minValues = data.min_values;
|
||||
this.label = data.label;
|
||||
this.value = data.value;
|
||||
this.options = data.options ?? [];
|
||||
this.placeholder = data.placeholder;
|
||||
}
|
||||
|
||||
readonly session: Session;
|
||||
|
||||
customId?: string;
|
||||
type: MessageComponentTypes;
|
||||
components?: Component[];
|
||||
disabled: boolean;
|
||||
emoji?: Emoji;
|
||||
maxValues?: number;
|
||||
minValues?: number;
|
||||
label?: string;
|
||||
value?: string;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
options: any[];
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export default Component;
|
47
structures/Interaction.ts
Normal file
47
structures/Interaction.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import type { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../util/Snowflake.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { DiscordInteraction, InteractionTypes } from "../vendor/external.ts";
|
||||
import User from "./User.ts";
|
||||
// import Member from "./Member.ts";
|
||||
|
||||
export class Interaction implements Model {
|
||||
constructor(session: Session, data: DiscordInteraction) {
|
||||
this.session = session;
|
||||
this.id = data.id;
|
||||
this.token = data.token;
|
||||
this.type = data.type
|
||||
this.guildId = data.guild_id;
|
||||
this.channelId = data.channel_id;
|
||||
this.applicationId = data.application_id;
|
||||
this.locale = data.locale;
|
||||
this.data = data.data;
|
||||
|
||||
if (!data.guild_id) {
|
||||
this.user = new User(session, data.user!);
|
||||
}
|
||||
else {
|
||||
// TODO: member transformer
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
readonly session: Session;
|
||||
readonly id: Snowflake;
|
||||
readonly token: string;
|
||||
|
||||
type: InteractionTypes;
|
||||
guildId?: Snowflake;
|
||||
channelId?: Snowflake;
|
||||
applicationId?: Snowflake;
|
||||
locale?: string;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
data: any;
|
||||
user?: User;
|
||||
|
||||
// TODO: do methods
|
||||
async respond() {
|
||||
}
|
||||
}
|
||||
|
||||
export default Interaction;
|
Loading…
x
Reference in New Issue
Block a user