Compare commits
2 commits
256956df73
...
6f8435b699
Author | SHA1 | Date | |
---|---|---|---|
powermaker450 | 6f8435b699 | ||
powermaker450 | 9da9926fac |
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 { Client } from "discord.js";
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 dotenv from "dotenv";
|
||||
import Logger from "../utils/Logger";
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 { REST, Routes } from "discord.js";
|
||||
import { commands } from "../commands";
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
export * from "./client";
|
||||
export * from "./config";
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
export type DeployCommandsProps = {
|
||||
guildId: string;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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,
|
||||
|
@ -26,11 +26,14 @@ 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")
|
||||
.setDescription("Send a confession")
|
||||
.addStringOption(option =>
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("message")
|
||||
.setRequired(true)
|
||||
|
@ -38,68 +41,76 @@ 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,
|
||||
});
|
||||
}
|
||||
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}\``)
|
||||
const confessChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||
.confessChannel;
|
||||
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||
.modChannel;
|
||||
// @ts-ignore
|
||||
.setDescription(messageContent);
|
||||
const messageContent = interaction.options.getString("message");
|
||||
|
||||
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 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,
|
||||
);
|
||||
|
||||
const message = await (
|
||||
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
||||
)
|
||||
.send({
|
||||
embeds: [userConfessionEmbed]
|
||||
return interaction.reply({
|
||||
content: "Confession sent!",
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
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,
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("An error occured:", err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,19 +14,26 @@
|
|||
*
|
||||
* 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 {
|
||||
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")
|
||||
.setDescription("Ban a user from submitting confessions.")
|
||||
.addStringOption(option =>
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("id")
|
||||
.setDescription("The confession ID to ban")
|
||||
.setRequired(true)
|
||||
.setRequired(true),
|
||||
)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
|
||||
|
||||
|
@ -34,16 +41,20 @@ export async function execute(interaction: CommandInteraction) {
|
|||
const result = dt.addBan(
|
||||
interaction.guild?.id!,
|
||||
// @ts-ignore
|
||||
interaction.options.getString("id")
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,22 +14,27 @@
|
|||
*
|
||||
* 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, EmbedBuilder, SlashCommandBuilder, TextChannel } from "discord.js";
|
||||
import {
|
||||
CommandInteraction,
|
||||
EmbedBuilder,
|
||||
SlashCommandBuilder,
|
||||
TextChannel,
|
||||
} from "discord.js";
|
||||
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")
|
||||
.setDescription("Deletes a confession")
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("id")
|
||||
.setDescription("The confession id")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option.setName("id").setDescription("The confession id").setRequired(true),
|
||||
);
|
||||
|
||||
export async function execute(interaction: CommandInteraction) {
|
||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||
|
@ -45,30 +50,41 @@ 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.",
|
||||
ephemeral: true
|
||||
content:
|
||||
"Either the confession wasn't found or you may not be allowed to remove it.",
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,36 +14,47 @@
|
|||
*
|
||||
* 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 {
|
||||
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")
|
||||
.setDescription("Unbans a user from confessions")
|
||||
.addStringOption(option =>
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("id")
|
||||
.setDescription("The confession ID to unban")
|
||||
.setRequired(true)
|
||||
.setRequired(true),
|
||||
)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
|
||||
|
||||
export function execute(interaction: CommandInteraction) {
|
||||
const result = dt.removeBan(
|
||||
interaction.guild?.id!,
|
||||
// @ts-ignore
|
||||
interaction.options.getString("id")
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 * as confess from "./confess";
|
||||
import * as confessdel from "./confessdel";
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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, SlashCommandBuilder } from "discord.js";
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 {
|
||||
ActionRowBuilder,
|
||||
|
@ -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("collect", async (ij) => {
|
||||
logChannel = ij.values[0];
|
||||
|
||||
await ij.update({
|
||||
content: "Setup Complete!",
|
||||
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: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
logCollector.on("end", (content) => {
|
||||
// If there is no content, follow up with an error message.
|
||||
!content.size &&
|
||||
collector.on("end", (collected) => {
|
||||
// Same as above logCollector end
|
||||
!collected.size &&
|
||||
interaction.followUp({
|
||||
content: "No channel selected. Please try again.",
|
||||
content: "No channel selected. 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);
|
||||
}
|
||||
}
|
||||
|
|
2
src/environment.d.ts
vendored
2
src/environment.d.ts
vendored
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 { BotClient, BOT_TOKEN, deployCommands } from "./bot";
|
||||
import { commands } from "./commands";
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 fs from "fs";
|
||||
import crypto from "crypto";
|
||||
|
@ -38,14 +38,14 @@ export class StoreMan {
|
|||
id: string,
|
||||
author: string,
|
||||
authorId: string,
|
||||
content: string
|
||||
content: string,
|
||||
): Confession {
|
||||
return {
|
||||
id: id,
|
||||
messageId: message.id,
|
||||
author: author,
|
||||
authorId: authorId,
|
||||
content: content
|
||||
content: content,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,13 @@ export class StoreMan {
|
|||
}
|
||||
|
||||
// Attempts to add a confession. Returns true if the confession is sent, false if otherwise.
|
||||
public addConfession(message: Message, id: string, author: string, authorId: string, content: string): boolean {
|
||||
public addConfession(
|
||||
message: Message,
|
||||
id: string,
|
||||
author: string,
|
||||
authorId: string,
|
||||
content: string,
|
||||
): boolean {
|
||||
const guildId = message.guild?.id;
|
||||
|
||||
for (const guild of this.data) {
|
||||
|
@ -127,7 +133,9 @@ export class StoreMan {
|
|||
return false;
|
||||
}
|
||||
|
||||
guild.confessions.push(StoreMan.toConfession(message, id, author, authorId, content));
|
||||
guild.confessions.push(
|
||||
StoreMan.toConfession(message, id, author, authorId, content),
|
||||
);
|
||||
this.saveFile();
|
||||
return true;
|
||||
}
|
||||
|
@ -138,7 +146,10 @@ export class StoreMan {
|
|||
);
|
||||
}
|
||||
|
||||
public getConfession(guildId: string, confessionId: string): Confession | null {
|
||||
public getConfession(
|
||||
guildId: string,
|
||||
confessionId: string,
|
||||
): Confession | null {
|
||||
for (const guild of this.data) {
|
||||
if (guild.id === guildId) {
|
||||
for (const confession of guild.confessions) {
|
||||
|
@ -153,7 +164,10 @@ export class StoreMan {
|
|||
}
|
||||
|
||||
// Attempts to delete a confession. If it is sucessfully deleted, returns true, else false.
|
||||
public delConfesssion({ guild, user }: CommandInteraction, confessionId: string): boolean {
|
||||
public delConfesssion(
|
||||
{ guild, user }: CommandInteraction,
|
||||
confessionId: string,
|
||||
): boolean {
|
||||
const guildId = guild?.id;
|
||||
const userId = user.id;
|
||||
|
||||
|
@ -161,7 +175,7 @@ export class StoreMan {
|
|||
if (guild.id === guildId) {
|
||||
for (const confession of guild.confessions) {
|
||||
if (confession.authorId === userId) {
|
||||
guild.confessions = guild.confessions.filter(confession => {
|
||||
guild.confessions = guild.confessions.filter((confession) => {
|
||||
return confession.id !== confessionId;
|
||||
});
|
||||
|
||||
|
@ -208,7 +222,8 @@ export class StoreMan {
|
|||
if (guild.id === guildId) {
|
||||
if (confession) {
|
||||
// Only add the user to the ban list if they aren't banned already
|
||||
!this.isBanned(guildId, confession.authorId) && guild.settings.bans.push(confession.authorId!);
|
||||
!this.isBanned(guildId, confession.authorId) &&
|
||||
guild.settings.bans.push(confession.authorId!);
|
||||
|
||||
this.saveFile();
|
||||
return true;
|
||||
|
@ -224,7 +239,7 @@ export class StoreMan {
|
|||
for (const guild of this.data) {
|
||||
if (guild.id === guildId) {
|
||||
if (this.getConfession(guildId, confessionId)) {
|
||||
guild.settings.bans = guild.settings.bans.filter(ban => {
|
||||
guild.settings.bans = guild.settings.bans.filter((ban) => {
|
||||
return ban !== this.getConfession(guildId, confessionId)?.authorId!;
|
||||
});
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
export * from "./client";
|
||||
export * from "./config";
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
export interface Confession {
|
||||
id: string;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 chalk from "chalk";
|
||||
import { LOG_LEVEL } from "./config";
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* 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 dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*
|
||||
* 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/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
const getRandomColor = () => (Math.random() * 0xFFFFFF << 0);
|
||||
const getRandomColor = () => (Math.random() * 0xffffff) << 0;
|
||||
|
||||
export default getRandomColor;
|
||||
|
|
Loading…
Reference in a new issue