mirror of
https://github.com/ION606/custom_discordjs.git
synced 2026-05-14 22:26:54 +00:00
Added base modals and 'finished' menus
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import gateWayEvents from '../gateway/dispatch.js'
|
||||
import { message } from '../messages/message.js';
|
||||
import {Interaction} from '../interactions/interaction.js';
|
||||
import Guild from '../guilds/Guild.js';
|
||||
import { createInteraction } from '../interactions/createInteraction.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ export default async function handleEvents(msgObj, token, client) {
|
||||
break;
|
||||
|
||||
case gateWayEvents.InteractionCreate:
|
||||
resolve({op: op, t: t, interaction: new Interaction(msgObj["d"], client)});
|
||||
resolve({op: op, t: t, interaction: createInteraction(msgObj["d"], client)}); //interaction: new Interaction(msgObj["d"], client)
|
||||
break;
|
||||
|
||||
case gateWayEvents.GuildCreate:
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Interaction } from "./interaction.js";
|
||||
|
||||
|
||||
export class Modal extends Interaction {
|
||||
constructor(intRaw, client) {
|
||||
super(intRaw, client);
|
||||
console.log(intRaw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Modal } from "./Modal.js";
|
||||
import { Interaction } from "./interaction.js";
|
||||
import { interactionTypes } from "./interactionTypes.js";
|
||||
|
||||
|
||||
function selectMenuTypes(inp) {
|
||||
|
||||
}
|
||||
|
||||
export function createInteraction(intRaw, client) {
|
||||
switch (intRaw.type) {
|
||||
case interactionTypes.ApplicationCommand:
|
||||
return new Interaction(intRaw, client);
|
||||
|
||||
case interactionTypes.MessageComponent:
|
||||
console.log(intRaw.message.components);
|
||||
return null;
|
||||
|
||||
case interactionTypes.ModalSubmit:
|
||||
return new Modal(intRaw, client);
|
||||
|
||||
case interactionTypes.Ping:
|
||||
console.log("pong");
|
||||
return null;
|
||||
|
||||
default: console.log(`UNKNOWN INTERACTION:\n`, intRaw);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ class interactionOptions {
|
||||
focused;
|
||||
|
||||
constructor(o) {
|
||||
console.log(o);
|
||||
for (const k in this) {
|
||||
if (o[k]) this[k] = o[k];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export const interactionTypes = Object.freeze({
|
||||
Ping: 1,
|
||||
ApplicationCommand: 2,
|
||||
MessageComponent: 3,
|
||||
ApplicationCommandAutocomplete: 4,
|
||||
ModalSubmit: 5
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Channel } from "../structures/guilds/Channel.js";
|
||||
import { message } from "../structures/messages/message.js";
|
||||
import { MessageButtonStyles } from "../structures/interactions/ButtonStyles.js";
|
||||
import { MessageActionRow } from "../structures/messages/MessageActionRow.js";
|
||||
import { ChannelSelectMenu, StringMenuComponent, StringSelectMenu } from "../structures/interactions/StringSelectMenu.js";
|
||||
import { ChannelSelectMenu, StringMenuComponent, StringSelectMenu, userSelectMenu } from "../structures/interactions/MessageSelectMenu.js";
|
||||
|
||||
/**
|
||||
* @param {message} mog
|
||||
@@ -21,10 +21,14 @@ export async function buttonTests(mog) {
|
||||
comp2.label = 'llllll';
|
||||
c.options.push(comp2);
|
||||
c.custom_id = "temp";
|
||||
|
||||
const comp3 = new userSelectMenu();
|
||||
comp3.custom_id = "userMenu";
|
||||
|
||||
const row = new MessageActionRow();
|
||||
// row.addComponent(comp);
|
||||
row.addComponent(c);
|
||||
// row.addComponent(c);
|
||||
row.addComponent(comp3);
|
||||
m.addComponents(row);
|
||||
m.content = "OOGA BOOGA";
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import { interactionTypes } from '../structures/interactions/interactionTypes.js';
|
||||
import { Interaction } from '../structures/types.js';
|
||||
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
/** @param {Interaction} interaction */
|
||||
export default async (interaction) => {
|
||||
console.log(interaction.data);
|
||||
interaction.reply({content: "HELLO WORLD", ephemeral: true});
|
||||
await delay(3000);
|
||||
interaction.update({content: "NOOOOOOOOOOOOOOOOOO"});
|
||||
await delay(2000);
|
||||
const response = await interaction.followUp("followup!");
|
||||
await delay(2000);
|
||||
response.delete();
|
||||
if (interaction.type == interactionTypes.ApplicationCommand) {
|
||||
console.log(interaction.data);
|
||||
interaction.reply({content: "HELLO WORLD", ephemeral: true});
|
||||
await delay(3000);
|
||||
interaction.update({content: "NOOOOOOOOOOOOOOOOOO"});
|
||||
await delay(2000);
|
||||
const response = await interaction.followUp("followup!");
|
||||
await delay(2000);
|
||||
response.delete();
|
||||
} else {
|
||||
console.log(interaction);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user