Compare commits
No commits in common. "d808ef0f156f7f5aabac21db8136c88a4009f2c0" and "cdbe79f2a24fb37f10668e221127262a74a293be" have entirely different histories.
d808ef0f15
...
cdbe79f2a2
|
@ -117,7 +117,6 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
|||
const adminConfessionEmbed = new EmbedBuilder()
|
||||
.setColor(color)
|
||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||
.setTimestamp(Date.now())
|
||||
.setDescription(messageContent)
|
||||
.addFields(
|
||||
{
|
||||
|
@ -137,14 +136,8 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
|||
.setLabel("Submit a Confession")
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
// const deleteConfessionButton = new ButtonBuilder()
|
||||
// .setCustomId("deleteConfession")
|
||||
// .setLabel("Delete")
|
||||
// .setStyle(ButtonStyle.Danger);
|
||||
|
||||
const actionRow = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
submitConfessionButton
|
||||
// deleteConfessionButton
|
||||
);
|
||||
|
||||
const message = await (
|
||||
|
@ -160,13 +153,7 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
|||
|
||||
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);
|
||||
i.showModal(submit);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
66
src/commands/confessban.ts
Normal file
66
src/commands/confessban.ts
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Confoss: Anonymous confessions for Discord, free as in freedom and price!
|
||||
* Copyright (C) 2024 powermaker450
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
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")
|
||||
.setDescription("Ban a user from submitting confessions.")
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("id")
|
||||
.setDescription("The confession ID to ban")
|
||||
.setRequired(true)
|
||||
)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
|
||||
|
||||
export async function execute(interaction: ChatInputCommandInteraction) {
|
||||
const guildId = interaction.guild?.id!;
|
||||
const confessionId = interaction.options.getString("id")!;
|
||||
|
||||
if (dt.isBanned(guildId, confessionId)) {
|
||||
return interaction.reply({
|
||||
content: "That user is already banned!",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
const result = dt.addBan(guildId, confessionId);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
55
src/commands/confessbanlist.ts
Normal file
55
src/commands/confessbanlist.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Confoss: Anonymous confessions for Discord, free as in freedom and price!
|
||||
* Copyright (C) 2024 powermaker450
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
CommandInteraction,
|
||||
PermissionFlagsBits,
|
||||
SlashCommandBuilder
|
||||
} from "discord.js";
|
||||
import { dt } from "../main";
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("confessbanlist")
|
||||
.setDescription("Get the current ban list")
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
|
||||
|
||||
export async function execute(interaction: CommandInteraction) {
|
||||
const bannedMembers = dt.getBans(interaction.guild?.id!);
|
||||
|
||||
let content = bannedMembers.length
|
||||
? "Banned Members:\n"
|
||||
: "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) {
|
||||
content += `\n<@${member.user}> | \`${member.confessionId}\``;
|
||||
}
|
||||
|
||||
return interaction.reply({
|
||||
content: content,
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
import {
|
||||
ChatInputCommandInteraction,
|
||||
EmbedBuilder,
|
||||
PermissionFlagsBits,
|
||||
SlashCommandBuilder,
|
||||
TextChannel
|
||||
} from "discord.js";
|
||||
|
@ -38,6 +37,7 @@ export const data = new SlashCommandBuilder()
|
|||
);
|
||||
|
||||
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!)) {
|
||||
return interaction.reply({
|
||||
|
@ -49,31 +49,22 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
|||
|
||||
const idVal = interaction.options.getString("id")!;
|
||||
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
||||
// If there is a result, and the user is either an author or has manage messages
|
||||
const allowedByUser = result && result.authorId === interaction.user.id;
|
||||
const allowedByMod =
|
||||
result &&
|
||||
interaction.memberPermissions?.has(PermissionFlagsBits.ManageMessages);
|
||||
|
||||
// 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 (allowedByUser || allowedByMod) {
|
||||
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")
|
||||
.setDescription(
|
||||
allowedByUser
|
||||
? "[Confession removed by user]"
|
||||
: "[Confession removed by moderator]"
|
||||
);
|
||||
|
||||
if (result) {
|
||||
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")
|
||||
.setDescription("[Confession Deleted]");
|
||||
|
||||
// Replace the given confession with an empty embed
|
||||
await (BotClient.channels.cache.get(channelId) as TextChannel).messages
|
||||
.fetch(confession!)
|
||||
|
@ -88,31 +79,13 @@ export async function execute(interaction: ChatInputCommandInteraction) {
|
|||
ephemeral: true
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("A confession delete error occured:", err);
|
||||
return interaction.reply({
|
||||
content: "An error occured.",
|
||||
ephemeral: true
|
||||
});
|
||||
logger.error("An error occured:", err);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
// If there was a result, the user wasn't allowed to remove it, otherwise it didn't exist.
|
||||
return result
|
||||
? interaction.reply({
|
||||
content: "You are not allowed to remove this confession.",
|
||||
ephemeral: true
|
||||
})
|
||||
: interaction.reply({
|
||||
content:
|
||||
"Either the confession wasn't found or you may not be allowed to remove it.",
|
||||
ephemeral: true
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("A confession delete interaction occured:", err);
|
||||
return interaction.reply({
|
||||
content: "An error occured.",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
return interaction.reply({
|
||||
content:
|
||||
"Either the confession wasn't found or you may not be allowed to remove it.",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
* Confoss: Anonymous confessions for Discord, free as in freedom and price!
|
||||
* Copyright (C) 2024 powermaker450
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
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("confessmod")
|
||||
.setDescription("Moderate confessions")
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
|
||||
.addSubcommand(ban =>
|
||||
ban
|
||||
.setName("ban")
|
||||
.setDescription("Ban a user from confessions")
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("id")
|
||||
.setDescription("The confession ID to ban")
|
||||
.setMinLength(4)
|
||||
.setMaxLength(4)
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand(list =>
|
||||
list.setName("list").setDescription("Show the list of banned users")
|
||||
)
|
||||
.addSubcommand(pardon =>
|
||||
pardon
|
||||
.setName("pardon")
|
||||
.setDescription("Unban a user from confessions")
|
||||
.addStringOption(id =>
|
||||
id
|
||||
.setName("id")
|
||||
.setDescription("The confession ID to ban")
|
||||
.setMinLength(4)
|
||||
.setMaxLength(4)
|
||||
.setRequired(true)
|
||||
)
|
||||
);
|
||||
|
||||
export async function execute(interaction: ChatInputCommandInteraction) {
|
||||
const guildId = interaction.guild?.id!;
|
||||
|
||||
// /confessmod ban <id>
|
||||
if (interaction.options.getSubcommand() === "ban") {
|
||||
const confessionId = interaction.options.getString("id")!;
|
||||
|
||||
if (dt.isBanned(guildId, confessionId)) {
|
||||
try {
|
||||
return interaction.reply({
|
||||
content: "That user is already banned!",
|
||||
ephemeral: true
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("A ban interaction error occured:", err);
|
||||
}
|
||||
}
|
||||
|
||||
const result = dt.addBan(guildId, confessionId);
|
||||
|
||||
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("A ban interaction error occured:", err);
|
||||
}
|
||||
// /confessmod list
|
||||
} else if (interaction.options.getSubcommand() === "list") {
|
||||
const bannedMembers = dt.getBans(interaction.guild?.id!);
|
||||
|
||||
let content = bannedMembers.length
|
||||
? "Banned Members:\n"
|
||||
: "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) {
|
||||
content += `\n<@${member.user}> | \`${member.confessionId}\``;
|
||||
}
|
||||
|
||||
try {
|
||||
return interaction.reply({
|
||||
content: content,
|
||||
ephemeral: true
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("A banlist interaction error occured:", err);
|
||||
}
|
||||
// /confessmod pardon <id>
|
||||
} else if (interaction.options.getSubcommand() === "pardon") {
|
||||
const result = dt.removeBan(
|
||||
interaction.guild?.id!,
|
||||
interaction.options.getString("id")!
|
||||
);
|
||||
|
||||
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 unban interaction error occured:", err);
|
||||
}
|
||||
}
|
||||
|
||||
return interaction.reply({
|
||||
content: "Unknown error",
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
59
src/commands/confesspardon.ts
Normal file
59
src/commands/confesspardon.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Confoss: Anonymous confessions for Discord, free as in freedom and price!
|
||||
* Copyright (C) 2024 powermaker450
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
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")
|
||||
.setDescription("Unbans a user from confessions")
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("id")
|
||||
.setDescription("The confession ID to unban")
|
||||
.setRequired(true)
|
||||
)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
|
||||
|
||||
export function execute(interaction: ChatInputCommandInteraction) {
|
||||
const result = dt.removeBan(
|
||||
interaction.guild?.id!,
|
||||
interaction.options.getString("id")!
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -18,14 +18,18 @@
|
|||
|
||||
import * as confess from "./confess";
|
||||
import * as confessdel from "./confessdel";
|
||||
import * as confessmod from "./confessmod";
|
||||
import * as confessban from "./confessban";
|
||||
import * as confessbanlist from "./confessbanlist";
|
||||
import * as confesspardon from "./confesspardon";
|
||||
import * as ping from "./ping";
|
||||
import * as setup from "./setup";
|
||||
|
||||
export const commands = {
|
||||
confess,
|
||||
confessdel,
|
||||
confessmod,
|
||||
confessban,
|
||||
confessbanlist,
|
||||
confesspardon,
|
||||
ping,
|
||||
setup
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue