Cast some nets
This commit is contained in:
parent
256956df73
commit
9da9926fac
|
@ -26,6 +26,9 @@ import { BotClient } from "../bot";
|
|||
import { dt } from "../main";
|
||||
import { StoreMan } from "../storeman";
|
||||
import getRandomColor from "../utils/getRandomColor";
|
||||
import Logger from "../utils/Logger";
|
||||
|
||||
const logger = new Logger("(/) confess");
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("confess")
|
||||
|
@ -38,68 +41,72 @@ export const data = new SlashCommandBuilder()
|
|||
);
|
||||
|
||||
export async function execute(interaction: CommandInteraction) {
|
||||
if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) {
|
||||
return interaction.reply({
|
||||
content: "You are banned from confessions in this server!",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
try {
|
||||
if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) {
|
||||
return interaction.reply({
|
||||
content: "You are banned from confessions in this server!",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||
return interaction.reply({
|
||||
content:
|
||||
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const confessChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||
.confessChannel;
|
||||
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||
.modChannel;
|
||||
// @ts-ignore
|
||||
const messageContent = interaction.options.getString("message");
|
||||
|
||||
const color = getRandomColor();
|
||||
const messageId = StoreMan.genId();
|
||||
const userConfessionEmbed = new EmbedBuilder()
|
||||
.setColor(color)
|
||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||
// @ts-ignore
|
||||
.setDescription(messageContent);
|
||||
|
||||
const adminConfessionEmbed = new EmbedBuilder()
|
||||
.setColor(color)
|
||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||
// @ts-ignore
|
||||
.setDescription(messageContent)
|
||||
.addFields({
|
||||
name: "Author",
|
||||
value: interaction.user.displayName
|
||||
},
|
||||
{
|
||||
name: "Author ID",
|
||||
value: interaction.user.id
|
||||
}
|
||||
);
|
||||
|
||||
const message = await (
|
||||
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
||||
)
|
||||
.send({
|
||||
embeds: [userConfessionEmbed]
|
||||
});
|
||||
|
||||
await (BotClient.channels.cache.get(adminChannel!) as TextChannel)
|
||||
.send({
|
||||
embeds: [adminConfessionEmbed]
|
||||
});
|
||||
|
||||
dt.addConfession(message, messageId, interaction.user.displayName, interaction.user.id, messageContent);
|
||||
|
||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||
return interaction.reply({
|
||||
content:
|
||||
"The bot hasn't been set up yet! Ask the server admins to set it up.",
|
||||
content: "Confession sent!",
|
||||
ephemeral: true,
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("An error occured:", err);
|
||||
}
|
||||
|
||||
|
||||
const confessChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||
.confessChannel;
|
||||
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||
.modChannel;
|
||||
// @ts-ignore
|
||||
const messageContent = interaction.options.getString("message");
|
||||
|
||||
const color = getRandomColor();
|
||||
const messageId = StoreMan.genId();
|
||||
const userConfessionEmbed = new EmbedBuilder()
|
||||
.setColor(color)
|
||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||
// @ts-ignore
|
||||
.setDescription(messageContent);
|
||||
|
||||
const adminConfessionEmbed = new EmbedBuilder()
|
||||
.setColor(color)
|
||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||
// @ts-ignore
|
||||
.setDescription(messageContent)
|
||||
.addFields({
|
||||
name: "Author",
|
||||
value: interaction.user.displayName
|
||||
},
|
||||
{
|
||||
name: "Author ID",
|
||||
value: interaction.user.id
|
||||
}
|
||||
);
|
||||
|
||||
const message = await (
|
||||
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
||||
)
|
||||
.send({
|
||||
embeds: [userConfessionEmbed]
|
||||
});
|
||||
|
||||
await (BotClient.channels.cache.get(adminChannel!) as TextChannel)
|
||||
.send({
|
||||
embeds: [adminConfessionEmbed]
|
||||
});
|
||||
|
||||
dt.addConfession(message, messageId, interaction.user.displayName, interaction.user.id, messageContent);
|
||||
|
||||
return interaction.reply({
|
||||
content: "Confession sent!",
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
import { CommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||
import { dt } from "../main";
|
||||
import Logger from "../utils/Logger";
|
||||
|
||||
const logger = new Logger("(/) confessban");
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("confessban")
|
||||
|
@ -37,13 +40,17 @@ export async function execute(interaction: CommandInteraction) {
|
|||
interaction.options.getString("id")
|
||||
);
|
||||
|
||||
return result
|
||||
? interaction.reply({
|
||||
content: "User was banned.",
|
||||
ephemeral: true
|
||||
})
|
||||
: interaction.reply({
|
||||
content: "No confession with that ID was found.",
|
||||
ephemeral: true
|
||||
});
|
||||
try {
|
||||
return result
|
||||
? interaction.reply({
|
||||
content: "User was banned.",
|
||||
ephemeral: true
|
||||
})
|
||||
: interaction.reply({
|
||||
content: "No confession with that ID was found.",
|
||||
ephemeral: true
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("An error occured:", err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ import { CommandInteraction, EmbedBuilder, SlashCommandBuilder, TextChannel } fr
|
|||
import { dt } from "../main";
|
||||
import { BotClient } from "../bot";
|
||||
import getRandomColor from "../utils/getRandomColor";
|
||||
import Logger from "../utils/Logger";
|
||||
|
||||
const logger = new Logger("(/) confessdel");
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("confessdel")
|
||||
|
@ -45,26 +48,30 @@ export async function execute(interaction: CommandInteraction) {
|
|||
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
||||
|
||||
if (result) {
|
||||
const confession = dt.getConfession(interaction.guild?.id!, idVal)?.messageId;
|
||||
const channelId = dt.getGuildInfo(interaction.guild?.id!)?.settings.confessChannel!;
|
||||
const emptyEmbed = new EmbedBuilder()
|
||||
.setColor(getRandomColor())
|
||||
.setTitle("Confession Deleted")
|
||||
// @ts-ignore
|
||||
.setDescription("[Confession Deleted]");
|
||||
try {
|
||||
const confession = dt.getConfession(interaction.guild?.id!, idVal)?.messageId;
|
||||
const channelId = dt.getGuildInfo(interaction.guild?.id!)?.settings.confessChannel!;
|
||||
const emptyEmbed = new EmbedBuilder()
|
||||
.setColor(getRandomColor())
|
||||
.setTitle("Confession Deleted")
|
||||
// @ts-ignore
|
||||
.setDescription("[Confession Deleted]");
|
||||
|
||||
await (BotClient.channels.cache.get(channelId) as TextChannel).messages.fetch(confession!).then(e => {
|
||||
e.edit({
|
||||
embeds: [emptyEmbed]
|
||||
})
|
||||
});
|
||||
await (BotClient.channels.cache.get(channelId) as TextChannel).messages.fetch(confession!).then(e => {
|
||||
e.edit({
|
||||
embeds: [emptyEmbed]
|
||||
})
|
||||
});
|
||||
|
||||
dt.delConfesssion(interaction, idVal);
|
||||
dt.delConfesssion(interaction, idVal);
|
||||
|
||||
return interaction.reply({
|
||||
content: "Confession removed.",
|
||||
ephemeral: true
|
||||
})
|
||||
return interaction.reply({
|
||||
content: "Confession removed.",
|
||||
ephemeral: true
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("An error occured:", err);
|
||||
}
|
||||
} else {
|
||||
return interaction.reply({
|
||||
content: "Either the confession wasn't found or you may not be allowed to remove it.",
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
import { CommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||
import { dt } from "../main";
|
||||
import Logger from "../utils/Logger";
|
||||
|
||||
const logger = new Logger("(/) confesspardon");
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("confesspardon")
|
||||
|
@ -37,13 +40,17 @@ export function execute(interaction: CommandInteraction) {
|
|||
interaction.options.getString("id")
|
||||
);
|
||||
|
||||
return result
|
||||
? interaction.reply({
|
||||
content: "User was unbanned.",
|
||||
ephemeral: true
|
||||
})
|
||||
: interaction.reply({
|
||||
content: "No confession with that ID was found.",
|
||||
ephemeral: true
|
||||
});
|
||||
try {
|
||||
return result
|
||||
? interaction.reply({
|
||||
content: "User was unbanned.",
|
||||
ephemeral: true
|
||||
})
|
||||
: interaction.reply({
|
||||
content: "No confession with that ID was found.",
|
||||
ephemeral: true
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("An error occured:", err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import {
|
|||
import { dt } from "../main";
|
||||
import Logger from "../utils/Logger";
|
||||
|
||||
const logger = new Logger("(/) setup");
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("setup")
|
||||
.setDescription("Setup the bot.")
|
||||
|
@ -52,83 +54,87 @@ export async function execute(interaction: CommandInteraction) {
|
|||
const channelRow =
|
||||
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(channelList);
|
||||
|
||||
const response = await interaction.reply({
|
||||
content: `# Let's get started, ${interaction.user.displayName}!\nFirst, let's choose a channel for your confessions.`,
|
||||
ephemeral: true,
|
||||
components: [channelRow],
|
||||
});
|
||||
|
||||
const collector = response.createMessageComponentCollector({
|
||||
componentType: ComponentType.ChannelSelect,
|
||||
time: 45_000,
|
||||
});
|
||||
|
||||
collector.on("collect", async (i) => {
|
||||
confessChannel = i.values[0];
|
||||
|
||||
await i.update({
|
||||
content: "Awesome!",
|
||||
components: [],
|
||||
});
|
||||
|
||||
collector.stop();
|
||||
|
||||
const logChannelList = new ChannelSelectMenuBuilder()
|
||||
.addChannelTypes(ChannelType.GuildText)
|
||||
.setCustomId("logChannels")
|
||||
.setPlaceholder("Choose a channel.");
|
||||
|
||||
const logChannelRow =
|
||||
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
|
||||
logChannelList,
|
||||
);
|
||||
|
||||
const logResponse = await interaction.followUp({
|
||||
content: "# Now, select a logging channel, for moderation purposes.",
|
||||
try {
|
||||
const response = await interaction.reply({
|
||||
content: `# Let's get started, ${interaction.user.displayName}!\nFirst, let's choose a channel for your confessions.`,
|
||||
ephemeral: true,
|
||||
components: [logChannelRow],
|
||||
components: [channelRow],
|
||||
});
|
||||
|
||||
const logCollector = logResponse.createMessageComponentCollector({
|
||||
const collector = response.createMessageComponentCollector({
|
||||
componentType: ComponentType.ChannelSelect,
|
||||
time: 45_000,
|
||||
});
|
||||
|
||||
logCollector.on("collect", async (ij) => {
|
||||
logChannel = ij.values[0];
|
||||
collector.on("collect", async (i) => {
|
||||
confessChannel = i.values[0];
|
||||
|
||||
await ij.update({
|
||||
content: "Setup Complete!",
|
||||
await i.update({
|
||||
content: "Awesome!",
|
||||
components: [],
|
||||
});
|
||||
|
||||
dt.setup(guildId!, {
|
||||
confessChannel: confessChannel,
|
||||
modChannel: logChannel,
|
||||
bans: [],
|
||||
collector.stop();
|
||||
|
||||
const logChannelList = new ChannelSelectMenuBuilder()
|
||||
.addChannelTypes(ChannelType.GuildText)
|
||||
.setCustomId("logChannels")
|
||||
.setPlaceholder("Choose a channel.");
|
||||
|
||||
const logChannelRow =
|
||||
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
|
||||
logChannelList,
|
||||
);
|
||||
|
||||
const logResponse = await interaction.followUp({
|
||||
content: "# Now, select a logging channel, for moderation purposes.",
|
||||
ephemeral: true,
|
||||
components: [logChannelRow],
|
||||
});
|
||||
|
||||
logCollector.stop();
|
||||
});
|
||||
const logCollector = logResponse.createMessageComponentCollector({
|
||||
componentType: ComponentType.ChannelSelect,
|
||||
time: 45_000,
|
||||
});
|
||||
|
||||
logCollector.on("end", (content) => {
|
||||
// If there is no content, follow up with an error message.
|
||||
!content.size &&
|
||||
interaction.followUp({
|
||||
content: "No channel selected. Please try again.",
|
||||
ephemeral: true,
|
||||
logCollector.on("collect", async (ij) => {
|
||||
logChannel = ij.values[0];
|
||||
|
||||
await ij.update({
|
||||
content: "Setup Complete!",
|
||||
components: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
collector.on("end", (collected) => {
|
||||
// Same as above logCollector end
|
||||
!collected.size &&
|
||||
interaction.followUp({
|
||||
content: "No channel selected. Try again.",
|
||||
ephemeral: true,
|
||||
components: []
|
||||
dt.setup(guildId!, {
|
||||
confessChannel: confessChannel,
|
||||
modChannel: logChannel,
|
||||
bans: [],
|
||||
});
|
||||
|
||||
logCollector.stop();
|
||||
});
|
||||
});
|
||||
|
||||
logCollector.on("end", (content) => {
|
||||
// If there is no content, follow up with an error message.
|
||||
!content.size &&
|
||||
interaction.followUp({
|
||||
content: "No channel selected. Please try again.",
|
||||
ephemeral: true,
|
||||
components: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
collector.on("end", (collected) => {
|
||||
// Same as above logCollector end
|
||||
!collected.size &&
|
||||
interaction.followUp({
|
||||
content: "No channel selected. Try again.",
|
||||
ephemeral: true,
|
||||
components: []
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("An error occured:", err);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue