Files

62 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2023-04-14 16:52:56 -04:00
import { Modal } from "./Modal.js";
import { Interaction } from "./interaction.js";
import { interactionTypes } from "./interactionTypes.js";
import * as msgMenu from './MessageSelectMenu.js';
2023-04-14 16:52:56 -04:00
/* inp.data
{ values: [ 'llllll' ], custom_id: 'temp', component_type: 3 }
2023-04-14 16:52:56 -04:00
{
values: [ '720349017829015633' ],
resolved: {
users: { '720349017829015633': [Object] },
members: { '720349017829015633': [Object] }
},
custom_id: 'userMenu',
component_type: 5
2023-04-14 16:52:56 -04:00
}
*/
function createSelectMenu(inp, client) {
// console.log(inp.data);//.filter(o => o.type in msgMenu.SelectMenuTypes);
switch (inp.data.component_type) {
case msgMenu.SelectMenuTypes.CHANNELS:
return new msgMenu.ChannelSelectMenu(inp.data, client);
case msgMenu.SelectMenuTypes.MENTIONABLE:
throw "MENTIONABLE MENUS NOT CURRENTLY SUPPORTED";
case msgMenu.SelectMenuTypes.ROLE:
return new msgMenu.RoleSelectMenu(inp.data, client);
case msgMenu.SelectMenuTypes.TEXT:
return new msgMenu.StringSelectMenu(inp.data, client);
case msgMenu.SelectMenuTypes.USER:
return new msgMenu.userSelectMenu(inp.data);
default: console.log("DEFAULT", inp.data);
}
}
2023-04-14 16:52:56 -04:00
export function createInteraction(intRaw, client) {
switch (intRaw.type) {
case interactionTypes.ApplicationCommand:
return new Interaction(intRaw, client);
case interactionTypes.MessageComponent:
return createSelectMenu(intRaw, client);
2023-04-14 16:52:56 -04:00
case interactionTypes.ModalSubmit:
2023-04-25 20:33:28 -04:00
// return console.log("MODALS NOT FULLY IMPLEMENTED!");
return new Modal(intRaw, client);
2023-04-14 16:52:56 -04:00
case interactionTypes.Ping:
console.log("pong");
return null;
default: console.log(`UNKNOWN INTERACTION:\n`, intRaw);
}
}