Compare commits
No commits in common. "ae27c7d24ec4cef7879d6b7c11d2ad8ad07a2f6d" and "e58239362c5f0dcdf690409ac6fd7d2d552fc1dc" have entirely different histories.
ae27c7d24e
...
e58239362c
|
@ -21,6 +21,7 @@ import {
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
|
ComponentType,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
TextChannel
|
TextChannel
|
||||||
|
@ -30,6 +31,7 @@ import { dt } from "../main";
|
||||||
import { StoreMan } from "../storeman";
|
import { StoreMan } from "../storeman";
|
||||||
import getRandomColor from "../utils/getRandomColor";
|
import getRandomColor from "../utils/getRandomColor";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
import { submit } from "../modals";
|
||||||
|
|
||||||
const logger = new Logger("(/) confess");
|
const logger = new Logger("(/) confess");
|
||||||
|
|
||||||
|
@ -41,7 +43,6 @@ export const data = new SlashCommandBuilder()
|
||||||
.setName("message")
|
.setName("message")
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.setDescription("What you want to confess")
|
.setDescription("What you want to confess")
|
||||||
.setMaxLength(2000)
|
|
||||||
)
|
)
|
||||||
.addStringOption(option =>
|
.addStringOption(option =>
|
||||||
option
|
option
|
||||||
|
@ -132,7 +133,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
isAttachment(attachment) && adminConfessionEmbed.setImage(attachment);
|
isAttachment(attachment) && adminConfessionEmbed.setImage(attachment);
|
||||||
|
|
||||||
const submitConfessionButton = new ButtonBuilder()
|
const submitConfessionButton = new ButtonBuilder()
|
||||||
.setCustomId("requestSubmit")
|
.setCustomId("submitConfession")
|
||||||
.setLabel("Submit a Confession")
|
.setLabel("Submit a Confession")
|
||||||
.setStyle(ButtonStyle.Primary);
|
.setStyle(ButtonStyle.Primary);
|
||||||
|
|
||||||
|
@ -153,6 +154,22 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
components: [actionRow]
|
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({
|
await (BotClient.channels.cache.get(adminChannel!) as TextChannel).send({
|
||||||
embeds: [adminConfessionEmbed]
|
embeds: [adminConfessionEmbed]
|
||||||
});
|
});
|
||||||
|
|
36
src/main.ts
36
src/main.ts
|
@ -81,28 +81,6 @@ 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 => {
|
BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
if (!interaction.isModalSubmit()) {
|
if (!interaction.isModalSubmit()) {
|
||||||
return;
|
return;
|
||||||
|
@ -143,6 +121,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
const userConfessionEmbed = new EmbedBuilder()
|
const userConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
|
// @ts-ignore
|
||||||
.setDescription(messageContent);
|
.setDescription(messageContent);
|
||||||
|
|
||||||
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
||||||
|
@ -150,6 +129,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
const adminConfessionEmbed = new EmbedBuilder()
|
const adminConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
|
// @ts-ignore
|
||||||
.setDescription(messageContent)
|
.setDescription(messageContent)
|
||||||
.addFields(
|
.addFields(
|
||||||
{
|
{
|
||||||
|
@ -165,7 +145,7 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
isAttachment(attachment) && adminConfessionEmbed.setImage(attachment);
|
isAttachment(attachment) && adminConfessionEmbed.setImage(attachment);
|
||||||
|
|
||||||
const submitConfessionButton = new ButtonBuilder()
|
const submitConfessionButton = new ButtonBuilder()
|
||||||
.setCustomId("requestSubmit")
|
.setCustomId("submitConfession")
|
||||||
.setLabel("Submit a Confession")
|
.setLabel("Submit a Confession")
|
||||||
.setStyle(ButtonStyle.Primary);
|
.setStyle(ButtonStyle.Primary);
|
||||||
|
|
||||||
|
@ -180,6 +160,16 @@ BotClient.on(Events.InteractionCreate, async interaction => {
|
||||||
components: [actionRow]
|
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({
|
await (BotClient.channels.cache.get(adminChannel!) as TextChannel).send({
|
||||||
embeds: [adminConfessionEmbed]
|
embeds: [adminConfessionEmbed]
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue