Compare commits
No commits in common. "6f8435b699bbb3a9af87e14f7eb3b9d75fcf0741" and "256956df73706c74c3209830a6d134a8745efc8a" have entirely different histories.
6f8435b699
...
256956df73
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Client } from "discord.js";
|
import { Client } from "discord.js";
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { REST, Routes } from "discord.js";
|
import { REST, Routes } from "discord.js";
|
||||||
import { commands } from "../commands";
|
import { commands } from "../commands";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from "./client";
|
export * from "./client";
|
||||||
export * from "./config";
|
export * from "./config";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export type DeployCommandsProps = {
|
export type DeployCommandsProps = {
|
||||||
guildId: string;
|
guildId: string;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CommandInteraction,
|
CommandInteraction,
|
||||||
|
@ -26,14 +26,11 @@ import { BotClient } from "../bot";
|
||||||
import { dt } from "../main";
|
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";
|
|
||||||
|
|
||||||
const logger = new Logger("(/) confess");
|
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName("confess")
|
.setName("confess")
|
||||||
.setDescription("Send a confession")
|
.setDescription("Send a confession")
|
||||||
.addStringOption((option) =>
|
.addStringOption(option =>
|
||||||
option
|
option
|
||||||
.setName("message")
|
.setName("message")
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
|
@ -41,11 +38,10 @@ export const data = new SlashCommandBuilder()
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function execute(interaction: CommandInteraction) {
|
export async function execute(interaction: CommandInteraction) {
|
||||||
try {
|
|
||||||
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!",
|
||||||
ephemeral: true,
|
ephemeral: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +53,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const confessChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
const confessChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||||
.confessChannel;
|
.confessChannel;
|
||||||
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||||
|
@ -77,40 +74,32 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
.setTitle(`Anonymous Confession \`${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.setDescription(messageContent)
|
.setDescription(messageContent)
|
||||||
.addFields(
|
.addFields({
|
||||||
{
|
|
||||||
name: "Author",
|
name: "Author",
|
||||||
value: interaction.user.displayName,
|
value: interaction.user.displayName
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Author ID",
|
name: "Author ID",
|
||||||
value: interaction.user.id,
|
value: interaction.user.id
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const message = await (
|
const message = await (
|
||||||
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
BotClient.channels.cache.get(confessChannel!) as TextChannel
|
||||||
).send({
|
)
|
||||||
embeds: [userConfessionEmbed],
|
.send({
|
||||||
|
embeds: [userConfessionEmbed]
|
||||||
});
|
});
|
||||||
|
|
||||||
await (BotClient.channels.cache.get(adminChannel!) as TextChannel).send({
|
await (BotClient.channels.cache.get(adminChannel!) as TextChannel)
|
||||||
embeds: [adminConfessionEmbed],
|
.send({
|
||||||
|
embeds: [adminConfessionEmbed]
|
||||||
});
|
});
|
||||||
|
|
||||||
dt.addConfession(
|
dt.addConfession(message, messageId, interaction.user.displayName, interaction.user.id, messageContent);
|
||||||
message,
|
|
||||||
messageId,
|
|
||||||
interaction.user.displayName,
|
|
||||||
interaction.user.id,
|
|
||||||
messageContent,
|
|
||||||
);
|
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Confession sent!",
|
content: "Confession sent!",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
logger.error("An error occured:", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,26 +14,19 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { CommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||||
CommandInteraction,
|
|
||||||
PermissionFlagsBits,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from "discord.js";
|
|
||||||
import { dt } from "../main";
|
import { dt } from "../main";
|
||||||
import Logger from "../utils/Logger";
|
|
||||||
|
|
||||||
const logger = new Logger("(/) confessban");
|
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName("confessban")
|
.setName("confessban")
|
||||||
.setDescription("Ban a user from submitting confessions.")
|
.setDescription("Ban a user from submitting confessions.")
|
||||||
.addStringOption((option) =>
|
.addStringOption(option =>
|
||||||
option
|
option
|
||||||
.setName("id")
|
.setName("id")
|
||||||
.setDescription("The confession ID to ban")
|
.setDescription("The confession ID to ban")
|
||||||
.setRequired(true),
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
|
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
|
||||||
|
|
||||||
|
@ -41,20 +34,16 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
const result = dt.addBan(
|
const result = dt.addBan(
|
||||||
interaction.guild?.id!,
|
interaction.guild?.id!,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
interaction.options.getString("id"),
|
interaction.options.getString("id")
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
|
||||||
return result
|
return result
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "User was banned.",
|
content: "User was banned.",
|
||||||
ephemeral: true,
|
ephemeral: true
|
||||||
})
|
})
|
||||||
: interaction.reply({
|
: interaction.reply({
|
||||||
content: "No confession with that ID was found.",
|
content: "No confession with that ID was found.",
|
||||||
ephemeral: true,
|
ephemeral: true
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
logger.error("An error occured:", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,27 +14,22 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { CommandInteraction, EmbedBuilder, SlashCommandBuilder, TextChannel } from "discord.js";
|
||||||
CommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
TextChannel,
|
|
||||||
} from "discord.js";
|
|
||||||
import { dt } from "../main";
|
import { dt } from "../main";
|
||||||
import { BotClient } from "../bot";
|
import { BotClient } from "../bot";
|
||||||
import getRandomColor from "../utils/getRandomColor";
|
import getRandomColor from "../utils/getRandomColor";
|
||||||
import Logger from "../utils/Logger";
|
|
||||||
|
|
||||||
const logger = new Logger("(/) confessdel");
|
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName("confessdel")
|
.setName("confessdel")
|
||||||
.setDescription("Deletes a confession")
|
.setDescription("Deletes a confession")
|
||||||
.addStringOption((option) =>
|
.addStringOption(option =>
|
||||||
option.setName("id").setDescription("The confession id").setRequired(true),
|
option
|
||||||
);
|
.setName("id")
|
||||||
|
.setDescription("The confession id")
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
|
||||||
export async function execute(interaction: CommandInteraction) {
|
export async function execute(interaction: CommandInteraction) {
|
||||||
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
if (!dt.getGuildInfo(interaction.guild?.id!)) {
|
||||||
|
@ -50,41 +45,30 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
try {
|
const confession = dt.getConfession(interaction.guild?.id!, idVal)?.messageId;
|
||||||
const confession = dt.getConfession(
|
const channelId = dt.getGuildInfo(interaction.guild?.id!)?.settings.confessChannel!;
|
||||||
interaction.guild?.id!,
|
|
||||||
idVal,
|
|
||||||
)?.messageId;
|
|
||||||
const channelId = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
|
||||||
.confessChannel!;
|
|
||||||
const emptyEmbed = new EmbedBuilder()
|
const emptyEmbed = new EmbedBuilder()
|
||||||
.setColor(getRandomColor())
|
.setColor(getRandomColor())
|
||||||
.setTitle("Confession Deleted")
|
.setTitle("Confession Deleted")
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.setDescription("[Confession Deleted]");
|
.setDescription("[Confession Deleted]");
|
||||||
|
|
||||||
await (BotClient.channels.cache.get(channelId) as TextChannel).messages
|
await (BotClient.channels.cache.get(channelId) as TextChannel).messages.fetch(confession!).then(e => {
|
||||||
.fetch(confession!)
|
|
||||||
.then((e) => {
|
|
||||||
e.edit({
|
e.edit({
|
||||||
embeds: [emptyEmbed],
|
embeds: [emptyEmbed]
|
||||||
});
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
dt.delConfesssion(interaction, idVal);
|
dt.delConfesssion(interaction, idVal);
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Confession removed.",
|
content: "Confession removed.",
|
||||||
ephemeral: true,
|
ephemeral: true
|
||||||
});
|
})
|
||||||
} catch (err) {
|
|
||||||
logger.error("An error occured:", err);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content:
|
content: "Either the confession wasn't found or you may not be allowed to remove it.",
|
||||||
"Either the confession wasn't found or you may not be allowed to remove it.",
|
ephemeral: true
|
||||||
ephemeral: true,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,47 +14,36 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { CommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||||
CommandInteraction,
|
|
||||||
PermissionFlagsBits,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from "discord.js";
|
|
||||||
import { dt } from "../main";
|
import { dt } from "../main";
|
||||||
import Logger from "../utils/Logger";
|
|
||||||
|
|
||||||
const logger = new Logger("(/) confesspardon");
|
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName("confesspardon")
|
.setName("confesspardon")
|
||||||
.setDescription("Unbans a user from confessions")
|
.setDescription("Unbans a user from confessions")
|
||||||
.addStringOption((option) =>
|
.addStringOption(option =>
|
||||||
option
|
option
|
||||||
.setName("id")
|
.setName("id")
|
||||||
.setDescription("The confession ID to unban")
|
.setDescription("The confession ID to unban")
|
||||||
.setRequired(true),
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages);
|
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
|
||||||
|
|
||||||
export function execute(interaction: CommandInteraction) {
|
export function execute(interaction: CommandInteraction) {
|
||||||
const result = dt.removeBan(
|
const result = dt.removeBan(
|
||||||
interaction.guild?.id!,
|
interaction.guild?.id!,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
interaction.options.getString("id"),
|
interaction.options.getString("id")
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
|
||||||
return result
|
return result
|
||||||
? interaction.reply({
|
? interaction.reply({
|
||||||
content: "User was unbanned.",
|
content: "User was unbanned.",
|
||||||
ephemeral: true,
|
ephemeral: true
|
||||||
})
|
})
|
||||||
: interaction.reply({
|
: interaction.reply({
|
||||||
content: "No confession with that ID was found.",
|
content: "No confession with that ID was found.",
|
||||||
ephemeral: true,
|
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
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as confess from "./confess";
|
import * as confess from "./confess";
|
||||||
import * as confessdel from "./confessdel";
|
import * as confessdel from "./confessdel";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
|
@ -28,8 +28,6 @@ import {
|
||||||
import { dt } from "../main";
|
import { dt } from "../main";
|
||||||
import Logger from "../utils/Logger";
|
import Logger from "../utils/Logger";
|
||||||
|
|
||||||
const logger = new Logger("(/) setup");
|
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName("setup")
|
.setName("setup")
|
||||||
.setDescription("Setup the bot.")
|
.setDescription("Setup the bot.")
|
||||||
|
@ -54,7 +52,6 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
const channelRow =
|
const channelRow =
|
||||||
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(channelList);
|
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(channelList);
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await interaction.reply({
|
const response = await interaction.reply({
|
||||||
content: `# Let's get started, ${interaction.user.displayName}!\nFirst, let's choose a channel for your confessions.`,
|
content: `# Let's get started, ${interaction.user.displayName}!\nFirst, let's choose a channel for your confessions.`,
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
|
@ -131,10 +128,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
interaction.followUp({
|
interaction.followUp({
|
||||||
content: "No channel selected. Try again.",
|
content: "No channel selected. Try again.",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
components: [],
|
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
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace NodeJS {
|
namespace NodeJS {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BotClient, BOT_TOKEN, deployCommands } from "./bot";
|
import { BotClient, BOT_TOKEN, deployCommands } from "./bot";
|
||||||
import { commands } from "./commands";
|
import { commands } from "./commands";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
|
@ -38,14 +38,14 @@ export class StoreMan {
|
||||||
id: string,
|
id: string,
|
||||||
author: string,
|
author: string,
|
||||||
authorId: string,
|
authorId: string,
|
||||||
content: string,
|
content: string
|
||||||
): Confession {
|
): Confession {
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
messageId: message.id,
|
messageId: message.id,
|
||||||
author: author,
|
author: author,
|
||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
content: content,
|
content: content
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,13 +117,7 @@ export class StoreMan {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempts to add a confession. Returns true if the confession is sent, false if otherwise.
|
// Attempts to add a confession. Returns true if the confession is sent, false if otherwise.
|
||||||
public addConfession(
|
public addConfession(message: Message, id: string, author: string, authorId: string, content: string): boolean {
|
||||||
message: Message,
|
|
||||||
id: string,
|
|
||||||
author: string,
|
|
||||||
authorId: string,
|
|
||||||
content: string,
|
|
||||||
): boolean {
|
|
||||||
const guildId = message.guild?.id;
|
const guildId = message.guild?.id;
|
||||||
|
|
||||||
for (const guild of this.data) {
|
for (const guild of this.data) {
|
||||||
|
@ -133,9 +127,7 @@ export class StoreMan {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.confessions.push(
|
guild.confessions.push(StoreMan.toConfession(message, id, author, authorId, content));
|
||||||
StoreMan.toConfession(message, id, author, authorId, content),
|
|
||||||
);
|
|
||||||
this.saveFile();
|
this.saveFile();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -146,10 +138,7 @@ export class StoreMan {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getConfession(
|
public getConfession(guildId: string, confessionId: string): Confession | null {
|
||||||
guildId: string,
|
|
||||||
confessionId: string,
|
|
||||||
): Confession | null {
|
|
||||||
for (const guild of this.data) {
|
for (const guild of this.data) {
|
||||||
if (guild.id === guildId) {
|
if (guild.id === guildId) {
|
||||||
for (const confession of guild.confessions) {
|
for (const confession of guild.confessions) {
|
||||||
|
@ -164,10 +153,7 @@ export class StoreMan {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempts to delete a confession. If it is sucessfully deleted, returns true, else false.
|
// Attempts to delete a confession. If it is sucessfully deleted, returns true, else false.
|
||||||
public delConfesssion(
|
public delConfesssion({ guild, user }: CommandInteraction, confessionId: string): boolean {
|
||||||
{ guild, user }: CommandInteraction,
|
|
||||||
confessionId: string,
|
|
||||||
): boolean {
|
|
||||||
const guildId = guild?.id;
|
const guildId = guild?.id;
|
||||||
const userId = user.id;
|
const userId = user.id;
|
||||||
|
|
||||||
|
@ -175,7 +161,7 @@ export class StoreMan {
|
||||||
if (guild.id === guildId) {
|
if (guild.id === guildId) {
|
||||||
for (const confession of guild.confessions) {
|
for (const confession of guild.confessions) {
|
||||||
if (confession.authorId === userId) {
|
if (confession.authorId === userId) {
|
||||||
guild.confessions = guild.confessions.filter((confession) => {
|
guild.confessions = guild.confessions.filter(confession => {
|
||||||
return confession.id !== confessionId;
|
return confession.id !== confessionId;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -222,8 +208,7 @@ export class StoreMan {
|
||||||
if (guild.id === guildId) {
|
if (guild.id === guildId) {
|
||||||
if (confession) {
|
if (confession) {
|
||||||
// Only add the user to the ban list if they aren't banned already
|
// Only add the user to the ban list if they aren't banned already
|
||||||
!this.isBanned(guildId, confession.authorId) &&
|
!this.isBanned(guildId, confession.authorId) && guild.settings.bans.push(confession.authorId!);
|
||||||
guild.settings.bans.push(confession.authorId!);
|
|
||||||
|
|
||||||
this.saveFile();
|
this.saveFile();
|
||||||
return true;
|
return true;
|
||||||
|
@ -239,7 +224,7 @@ export class StoreMan {
|
||||||
for (const guild of this.data) {
|
for (const guild of this.data) {
|
||||||
if (guild.id === guildId) {
|
if (guild.id === guildId) {
|
||||||
if (this.getConfession(guildId, confessionId)) {
|
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!;
|
return ban !== this.getConfession(guildId, confessionId)?.authorId!;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from "./client";
|
export * from "./client";
|
||||||
export * from "./config";
|
export * from "./config";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface Confession {
|
export interface Confession {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { LOG_LEVEL } from "./config";
|
import { LOG_LEVEL } from "./config";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* 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;
|
export default getRandomColor;
|
||||||
|
|
Loading…
Reference in a new issue