Comment some funky looking stuff
This commit is contained in:
parent
4b6a413f85
commit
fb8a9500e7
|
@ -54,6 +54,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
// TODO: This all works as intended, but I'd like for it so be a reusable function
|
// TODO: This all works as intended, but I'd like for it so be a reusable function
|
||||||
// instead because all of this is used in src/main.ts
|
// instead because all of this is used in src/main.ts
|
||||||
try {
|
try {
|
||||||
|
// If the user is banned in this guild, don't let them post
|
||||||
if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) {
|
if (dt.isBanned(interaction.guild?.id!, interaction.user.id)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "You are banned from confessions in this server!",
|
content: "You are banned from confessions in this server!",
|
||||||
|
@ -61,6 +62,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no guild info is present for this guild, don't let the user post
|
||||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
|
@ -82,6 +84,15 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
const color = getRandomColor();
|
const color = getRandomColor();
|
||||||
const messageId = StoreMan.genId();
|
const messageId = StoreMan.genId();
|
||||||
|
|
||||||
|
// Looks like:
|
||||||
|
//
|
||||||
|
// |
|
||||||
|
// | Anonymous Confession a1b2
|
||||||
|
// |
|
||||||
|
// | "example confession content"
|
||||||
|
// |
|
||||||
|
//
|
||||||
const userConfessionEmbed = new EmbedBuilder()
|
const userConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
|
@ -89,6 +100,20 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
isAttachment(attachment) && userConfessionEmbed.setImage(attachment);
|
||||||
|
|
||||||
|
// Looks like:
|
||||||
|
//
|
||||||
|
// |
|
||||||
|
// | Anonymous Confession a1b2
|
||||||
|
// |
|
||||||
|
// | "example confession content"
|
||||||
|
// |
|
||||||
|
// | Author
|
||||||
|
// | @user1
|
||||||
|
// |
|
||||||
|
// | Author ID
|
||||||
|
// | 1234567890
|
||||||
|
// |
|
||||||
|
//
|
||||||
const adminConfessionEmbed = new EmbedBuilder()
|
const adminConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
|
@ -148,6 +173,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const confessionsLength = dt.getGuildInfo(interaction.guild?.id!)
|
const confessionsLength = dt.getGuildInfo(interaction.guild?.id!)
|
||||||
?.confessions.length!;
|
?.confessions.length!;
|
||||||
|
|
||||||
|
// If there are 2 or more confessions, remove the previous confession's button components
|
||||||
if (confessionsLength >= 2) {
|
if (confessionsLength >= 2) {
|
||||||
await (
|
await (
|
||||||
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
||||||
|
|
|
@ -35,6 +35,15 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
? "Banned Members:\n"
|
? "Banned Members:\n"
|
||||||
: "There are no banned members.";
|
: "There are no banned members.";
|
||||||
|
|
||||||
|
// For each member, add them to the message content.
|
||||||
|
// It will end up looking something like this:
|
||||||
|
//
|
||||||
|
// Banned Members:
|
||||||
|
//
|
||||||
|
// @user1 | a1b2
|
||||||
|
// @user2 | c3d4
|
||||||
|
// @user3 | e5f6
|
||||||
|
//
|
||||||
for (const member of bannedMembers) {
|
for (const member of bannedMembers) {
|
||||||
content += `\n<@${member.user}> | \`${member.confessionId}\``;
|
content += `\n<@${member.user}> | \`${member.confessionId}\``;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
CommandInteraction,
|
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
TextChannel
|
TextChannel
|
||||||
|
@ -38,6 +37,8 @@ export const data = new SlashCommandBuilder()
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function execute(interaction: ChatInputCommandInteraction) {
|
export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
|
||||||
|
// If there is no guild info, don't let the user delete anything
|
||||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content:
|
||||||
|
@ -49,6 +50,8 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const idVal = interaction.options.getString("id")!;
|
const idVal = interaction.options.getString("id")!;
|
||||||
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
||||||
|
|
||||||
|
// If a confession is found with the given ID, check if the user is the one that posted it, and delete it if they are.
|
||||||
|
// Otherwise, don't let the user delete anything.
|
||||||
if (result) {
|
if (result) {
|
||||||
try {
|
try {
|
||||||
const confession = dt.getConfession(
|
const confession = dt.getConfession(
|
||||||
|
@ -60,9 +63,9 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
||||||
const emptyEmbed = new EmbedBuilder()
|
const emptyEmbed = new EmbedBuilder()
|
||||||
.setColor(getRandomColor())
|
.setColor(getRandomColor())
|
||||||
.setTitle("Confession Deleted")
|
.setTitle("Confession Deleted")
|
||||||
// @ts-ignore
|
|
||||||
.setDescription("[Confession Deleted]");
|
.setDescription("[Confession Deleted]");
|
||||||
|
|
||||||
|
// Replace the given confession with an empty embed
|
||||||
await (BotClient.channels.cache.get(channelId) as TextChannel).messages
|
await (BotClient.channels.cache.get(channelId) as TextChannel).messages
|
||||||
.fetch(confession!)
|
.fetch(confession!)
|
||||||
.then(e => {
|
.then(e => {
|
||||||
|
|
Loading…
Reference in a new issue