Compare commits
2 commits
e58239362c
...
ae27c7d24e
Author | SHA1 | Date | |
---|---|---|---|
ae27c7d24e | |||
645a8b2ae7 |
|
@ -21,7 +21,6 @@ import {
|
|||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
ChatInputCommandInteraction,
|
||||
ComponentType,
|
||||
EmbedBuilder,
|
||||
SlashCommandBuilder,
|
||||
TextChannel
|
||||
|
@ -31,7 +30,6 @@ import { dt } from "../main";
|
|||
import { StoreMan } from "../storeman";
|
||||
import getRandomColor from "../utils/getRandomColor";
|
||||
import Logger from "../utils/Logger";
|
||||
import { submit } from "../modals";
|
||||
|
||||
const logger = new Logger("(/) confess");
|
||||
|
||||
|
@ -43,6 +41,7 @@ export const data = new SlashCommandBuilder()
|
|||
.setName("message")
|
||||
.setRequired(true)
|
||||
.setDescription("What you want to confess")
|
||||
.setMaxLength(2000)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
|
@ -133,7 +132,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
|||
isAttachment(attachment) && adminConfessionEmbed.setImage(attachment);
|
||||
|
||||
const submitConfessionButton = new ButtonBuilder()
|
||||
.setCustomId("submitConfession")
|
||||
.setCustomId("requestSubmit")
|
||||
.setLabel("Submit a Confession")
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
|
@ -154,22 +153,6 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
|||
components: [actionRow]
|
||||
});
|
||||
|
||||
const collector = message.createMessageComponentCollector({
|
||||
componentType: ComponentType.Button
|
||||
});
|
||||
|
||||
collector.on("collect", i => {
|
||||
if (i.customId === "submitConfession") {
|
||||
// Check if the user is banned from confessions first before displaying the modal
|
||||
dt.isBanned(i.guild.id, i.user.id)
|
||||
? i.reply({
|
||||
content: "You are banned from confessions in this server!",
|
||||
ephemeral: true
|
||||
})
|
||||
: i.showModal(submit);
|
||||
}
|
||||
});
|
||||
|
||||
await (BotClient.channels.cache.get(adminChannel!) as TextChannel).send({
|
||||
embeds: [adminConfessionEmbed]
|
||||
});
|
||||
|
|
36
src/main.ts
36
src/main.ts
|
@ -81,6 +81,28 @@ BotClient.on(Events.MessageDelete, async message => {
|
|||
}
|
||||
});
|
||||
|
||||
// Submit Confession button
|
||||
BotClient.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isButton()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Changed the id of the submit request button, but keep compatibility for now
|
||||
const requestSubmit =
|
||||
interaction.customId === "requestSubmit" ||
|
||||
interaction.customId === "submitConfession";
|
||||
|
||||
if (requestSubmit) {
|
||||
// Check if the user is banned from confessions before showing the modal
|
||||
dt.isBanned(interaction.guild?.id!, interaction.user.id)
|
||||
? interaction.reply({
|
||||
content: "You are banned from confessions in this server!",
|
||||
ephemeral: true
|
||||
})
|
||||
: interaction.showModal(submit);
|
||||
}
|
||||
});
|
||||
|
||||
BotClient.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isModalSubmit()) {
|
||||
return;
|
||||
|
@ -121,7 +143,6 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
|||
const userConfessionEmbed = new EmbedBuilder()
|
||||
.setColor(color)
|
||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||
// @ts-ignore
|
||||
.setDescription(messageContent);
|
||||
|
||||
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
||||
|
@ -129,7 +150,6 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
|||
const adminConfessionEmbed = new EmbedBuilder()
|
||||
.setColor(color)
|
||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||
// @ts-ignore
|
||||
.setDescription(messageContent)
|
||||
.addFields(
|
||||
{
|
||||
|
@ -145,7 +165,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
|||
isAttachment(attachment) && adminConfessionEmbed.setImage(attachment);
|
||||
|
||||
const submitConfessionButton = new ButtonBuilder()
|
||||
.setCustomId("submitConfession")
|
||||
.setCustomId("requestSubmit")
|
||||
.setLabel("Submit a Confession")
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
|
@ -160,16 +180,6 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
|||
components: [actionRow]
|
||||
});
|
||||
|
||||
const collector = message.createMessageComponentCollector({
|
||||
componentType: ComponentType.Button
|
||||
});
|
||||
|
||||
collector.on("collect", i => {
|
||||
if (i.customId === "submitConfession") {
|
||||
i.showModal(submit);
|
||||
}
|
||||
});
|
||||
|
||||
await (BotClient.channels.cache.get(adminChannel!) as TextChannel).send({
|
||||
embeds: [adminConfessionEmbed]
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue