Compare commits
10 commits
main
...
ellie-fix-
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ebfa37d93 | |||
| 28e5bd91a6 | |||
| 3160e979a0 | |||
| 622738fcf4 | |||
| 22bebaf064 | |||
| a0f8b02c55 | |||
| 5f27fedd86 | |||
| 1879eac26c | |||
| e21cb15c11 | |||
| de8e9b693c |
1 changed files with 31 additions and 23 deletions
|
|
@ -91,32 +91,40 @@ function registerInteractions() {
|
||||||
async function dispatchInteraction(interaction) {
|
async function dispatchInteraction(interaction) {
|
||||||
const interactionId = interaction.data?.["custom_id"] || interaction.data?.["name"]
|
const interactionId = interaction.data?.["custom_id"] || interaction.data?.["name"]
|
||||||
try {
|
try {
|
||||||
if (interactionId === "Matrix info") {
|
if (interaction.type === DiscordTypes.InteractionType.MessageComponent || interaction.type === DiscordTypes.InteractionType.ModalSubmit) {
|
||||||
await matrixInfo.interact(interaction)
|
// All we get is custom_id, don't know which context the button was clicked in.
|
||||||
} else if (interactionId === "invite") {
|
// So we namespace these ourselves in the custom_id. Currently the only existing namespace is POLL_.
|
||||||
await invite.interact(interaction)
|
if (interaction.data.custom_id.startsWith("POLL_")) {
|
||||||
} else if (interactionId === "invite_channel") {
|
await poll.interact(interaction)
|
||||||
await invite.interactButton(interaction)
|
|
||||||
} else if (interactionId === "Permissions") {
|
|
||||||
await permissions.interact(interaction)
|
|
||||||
} else if (interactionId === "permissions_edit") {
|
|
||||||
await permissions.interactEdit(interaction)
|
|
||||||
} else if (interactionId === "Responses") {
|
|
||||||
/** @type {DiscordTypes.APIMessageApplicationCommandGuildInteraction} */ // @ts-ignore
|
|
||||||
const messageInteraction = interaction
|
|
||||||
if (select("poll", "message_id", {message_id: messageInteraction.data.target_id}).get()) {
|
|
||||||
await pollResponses.interact(messageInteraction)
|
|
||||||
} else {
|
} else {
|
||||||
await reactions.interact(messageInteraction)
|
throw new Error(`Unknown message component ${interaction.data.custom_id}`)
|
||||||
}
|
}
|
||||||
} else if (interactionId === "ping") {
|
|
||||||
await ping.interact(interaction)
|
|
||||||
} else if (interactionId === "privacy") {
|
|
||||||
await privacy.interact(interaction)
|
|
||||||
} else if (interactionId.startsWith("POLL_")) {
|
|
||||||
await poll.interact(interaction)
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unknown interaction ${interactionId}`)
|
if (interactionId === "Matrix info") {
|
||||||
|
await matrixInfo.interact(interaction)
|
||||||
|
} else if (interactionId === "invite") {
|
||||||
|
await invite.interact(interaction)
|
||||||
|
} else if (interactionId === "invite_channel") {
|
||||||
|
await invite.interactButton(interaction)
|
||||||
|
} else if (interactionId === "Permissions") {
|
||||||
|
await permissions.interact(interaction)
|
||||||
|
} else if (interactionId === "permissions_edit") {
|
||||||
|
await permissions.interactEdit(interaction)
|
||||||
|
} else if (interactionId === "Responses") {
|
||||||
|
/** @type {DiscordTypes.APIMessageApplicationCommandGuildInteraction} */ // @ts-ignore
|
||||||
|
const messageInteraction = interaction
|
||||||
|
if (select("poll", "message_id", {message_id: messageInteraction.data.target_id}).get()) {
|
||||||
|
await pollResponses.interact(messageInteraction)
|
||||||
|
} else {
|
||||||
|
await reactions.interact(messageInteraction)
|
||||||
|
}
|
||||||
|
} else if (interactionId === "ping") {
|
||||||
|
await ping.interact(interaction)
|
||||||
|
} else if (interactionId === "privacy") {
|
||||||
|
await privacy.interact(interaction)
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unknown interaction ${interactionId}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let stackLines = null
|
let stackLines = null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue