mirror of
https://github.com/Team-Neptune/Korral-JS.git
synced 2025-02-18 10:57:31 +00:00
Add use_modal param to speak command
This commit is contained in:
parent
af78c3dc60
commit
d8f2e77a73
@ -546,6 +546,12 @@ const utilityCommands: ApplicationCommandOptionData[] = [
|
||||
description: "Whether or not to have pings (allowed_mentions)",
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
type: "BOOLEAN",
|
||||
name: "use_modal",
|
||||
description: "Use Modal to send text instead of provided text param",
|
||||
required: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
@ -9,6 +9,49 @@ export default new Command({
|
||||
let text = interaction.options.getString("text");
|
||||
let disable_ping: boolean =
|
||||
interaction.options.getBoolean("disable_ping", false) || false;
|
||||
let use_modal: boolean =
|
||||
interaction.options.getBoolean("use_modal", false) || false;
|
||||
|
||||
if (use_modal)
|
||||
return (
|
||||
// @ts-expect-error
|
||||
interaction.client.api
|
||||
// @ts-expect-error
|
||||
.interactions(interaction.id)(interaction.token)
|
||||
.callback.post({
|
||||
data: {
|
||||
type: 9,
|
||||
data: {
|
||||
components: [
|
||||
{
|
||||
type: 1,
|
||||
components: [
|
||||
{
|
||||
type: 4,
|
||||
custom_id: "text",
|
||||
style: 2,
|
||||
label: "Text",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 1,
|
||||
components: [
|
||||
{
|
||||
type: 4,
|
||||
custom_id: "mentions_disabled",
|
||||
style: 2,
|
||||
label: "Disable mentions? true/false",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
title: "Speak: Large Input",
|
||||
custom_id: "speak_large_input",
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
let responseMessage: MessageOptions = {
|
||||
content: text,
|
||||
|
39
src/modals/speak_large_input.ts
Normal file
39
src/modals/speak_large_input.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { MessageOptions, ThreadChannel } from "discord.js";
|
||||
import { config } from "../../config";
|
||||
import ModalCommand from "../classes/ModalCommand";
|
||||
|
||||
export default new ModalCommand({
|
||||
customId: "speak_large_input",
|
||||
staffOnly: true,
|
||||
async execute(interaction, client) {
|
||||
let messageText =
|
||||
interaction.data.components[0]?.components[0]?.value || "";
|
||||
let disable_ping = Boolean(
|
||||
interaction.data.components[1]?.components[0]?.value || false
|
||||
);
|
||||
// @ts-expect-error
|
||||
client.api
|
||||
//@ts-expect-error
|
||||
.interactions(interaction.id)(interaction.token)
|
||||
.callback.post({
|
||||
data: {
|
||||
type: 4,
|
||||
data: {
|
||||
content: `Sent!`,
|
||||
flags: 64,
|
||||
},
|
||||
},
|
||||
});
|
||||
let channel = client.channels.cache.get(interaction.channel_id);
|
||||
if (channel.isText()) {
|
||||
let responseMessage: MessageOptions = {
|
||||
content: messageText,
|
||||
};
|
||||
if (disable_ping)
|
||||
responseMessage.allowedMentions = {
|
||||
parse: [],
|
||||
};
|
||||
channel.send(responseMessage);
|
||||
}
|
||||
},
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user