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 gateWayEvents from '../gateway/dispatch.js'
|
||||||
import { message } from '../messages/message.js';
|
import { message } from '../messages/message.js';
|
||||||
import {Interaction} from '../interactions/interaction.js';
|
|
||||||
import Guild from '../guilds/Guild.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;
|
break;
|
||||||
|
|
||||||
case gateWayEvents.InteractionCreate:
|
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;
|
break;
|
||||||
|
|
||||||
case gateWayEvents.GuildCreate:
|
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;
|
focused;
|
||||||
|
|
||||||
constructor(o) {
|
constructor(o) {
|
||||||
|
console.log(o);
|
||||||
for (const k in this) {
|
for (const k in this) {
|
||||||
if (o[k]) this[k] = o[k];
|
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 { message } from "../structures/messages/message.js";
|
||||||
import { MessageButtonStyles } from "../structures/interactions/ButtonStyles.js";
|
import { MessageButtonStyles } from "../structures/interactions/ButtonStyles.js";
|
||||||
import { MessageActionRow } from "../structures/messages/MessageActionRow.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
|
* @param {message} mog
|
||||||
@@ -22,9 +22,13 @@ export async function buttonTests(mog) {
|
|||||||
c.options.push(comp2);
|
c.options.push(comp2);
|
||||||
c.custom_id = "temp";
|
c.custom_id = "temp";
|
||||||
|
|
||||||
|
const comp3 = new userSelectMenu();
|
||||||
|
comp3.custom_id = "userMenu";
|
||||||
|
|
||||||
const row = new MessageActionRow();
|
const row = new MessageActionRow();
|
||||||
// row.addComponent(comp);
|
// row.addComponent(comp);
|
||||||
row.addComponent(c);
|
// row.addComponent(c);
|
||||||
|
row.addComponent(comp3);
|
||||||
m.addComponents(row);
|
m.addComponents(row);
|
||||||
m.content = "OOGA BOOGA";
|
m.content = "OOGA BOOGA";
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
|
import { interactionTypes } from '../structures/interactions/interactionTypes.js';
|
||||||
import { Interaction } from '../structures/types.js';
|
import { Interaction } from '../structures/types.js';
|
||||||
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|
||||||
/** @param {Interaction} interaction */
|
/** @param {Interaction} interaction */
|
||||||
export default async (interaction) => {
|
export default async (interaction) => {
|
||||||
console.log(interaction.data);
|
if (interaction.type == interactionTypes.ApplicationCommand) {
|
||||||
interaction.reply({content: "HELLO WORLD", ephemeral: true});
|
console.log(interaction.data);
|
||||||
await delay(3000);
|
interaction.reply({content: "HELLO WORLD", ephemeral: true});
|
||||||
interaction.update({content: "NOOOOOOOOOOOOOOOOOO"});
|
await delay(3000);
|
||||||
await delay(2000);
|
interaction.update({content: "NOOOOOOOOOOOOOOOOOO"});
|
||||||
const response = await interaction.followUp("followup!");
|
await delay(2000);
|
||||||
await delay(2000);
|
const response = await interaction.followUp("followup!");
|
||||||
response.delete();
|
await delay(2000);
|
||||||
|
response.delete();
|
||||||
|
} else {
|
||||||
|
console.log(interaction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user