- fix multiple responses to single interaction
This commit is contained in:
parent
c018d35e2a
commit
401329bff1
@ -8,7 +8,8 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"database:migrate": "yarn prisma migrate dev",
|
"database:migrate": "yarn prisma migrate dev",
|
||||||
"dev": "nodemon --watch './**/*.ts' --exec 'ts-node --esm -r tsconfig-paths/register ./src/index.ts'"
|
"dev": "nodemon --watch './**/*.ts' --exec 'ts-node --esm -r tsconfig-paths/register ./src/index.ts'",
|
||||||
|
"start": "ts-node --esm -r tsconfig-paths/register ./src/index.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.7.18",
|
"@types/node": "^18.7.18",
|
||||||
@ -28,4 +29,4 @@
|
|||||||
"dotenv": "^16.0.2",
|
"dotenv": "^16.0.2",
|
||||||
"node-cleanup": "^2.1.2"
|
"node-cleanup": "^2.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,13 +32,9 @@ export default class DiscordController extends EventEmitter {
|
|||||||
async handleInteraction(interaction: Interaction<CacheType>) {
|
async handleInteraction(interaction: Interaction<CacheType>) {
|
||||||
if (interaction.isModalSubmit()) {
|
if (interaction.isModalSubmit()) {
|
||||||
await this.handleModalSubmit(interaction);
|
await this.handleModalSubmit(interaction);
|
||||||
}
|
} else if (interaction.isChatInputCommand()) {
|
||||||
|
|
||||||
if (interaction.isChatInputCommand()) {
|
|
||||||
await this.handleChatInputCommand(interaction);
|
await this.handleChatInputCommand(interaction);
|
||||||
}
|
} else if (interaction.isButton()) {
|
||||||
|
|
||||||
if (interaction.isButton()) {
|
|
||||||
await this.handleButton(interaction);
|
await this.handleButton(interaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,11 +55,13 @@ export default class DiscordController extends EventEmitter {
|
|||||||
switch (commandName) {
|
switch (commandName) {
|
||||||
case "quote":
|
case "quote":
|
||||||
await this.discordService.handleQuote(interaction);
|
await this.discordService.handleQuote(interaction);
|
||||||
|
return;
|
||||||
case "quotemodal":
|
case "quotemodal":
|
||||||
await this.discordService.handleQuoteModal(interaction);
|
await this.discordService.handleQuoteModal(interaction);
|
||||||
|
return;
|
||||||
case "actions":
|
case "actions":
|
||||||
await this.discordService.handleActions(interaction);
|
await this.discordService.handleActions(interaction);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -75,10 +73,9 @@ export default class DiscordController extends EventEmitter {
|
|||||||
switch (customId) {
|
switch (customId) {
|
||||||
case "quoteModal":
|
case "quoteModal":
|
||||||
await this.discordService.handleQuote(interaction);
|
await this.discordService.handleQuote(interaction);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendActions(interaction: ChatInputCommandInteraction<CacheType>) {}
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,11 @@ export default class DiscordService {
|
|||||||
const modal = getQuoteModal();
|
const modal = getQuoteModal();
|
||||||
|
|
||||||
if (interaction.isButton() || interaction.isChatInputCommand()) {
|
if (interaction.isButton() || interaction.isChatInputCommand()) {
|
||||||
await interaction.showModal(modal);
|
try {
|
||||||
|
await interaction.showModal(modal);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +106,14 @@ export default class DiscordService {
|
|||||||
await channel.send(content);
|
await channel.send(content);
|
||||||
|
|
||||||
if (interaction.isChatInputCommand() || interaction.isModalSubmit()) {
|
if (interaction.isChatInputCommand() || interaction.isModalSubmit()) {
|
||||||
await interaction.reply({
|
try {
|
||||||
content: "Completed!",
|
await interaction.reply({
|
||||||
ephemeral: true,
|
content: "Completed!",
|
||||||
});
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user