Compare commits
2 commits
5b2fa6e93f
...
63752cf3c7
Author | SHA1 | Date | |
---|---|---|---|
powermaker450 | 63752cf3c7 | ||
powermaker450 | 683a2c6097 |
|
@ -58,20 +58,22 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
.confessChannel;
|
.confessChannel;
|
||||||
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
const adminChannel = dt.getGuildInfo(interaction.guild?.id!)?.settings
|
||||||
.modChannel;
|
.modChannel;
|
||||||
|
// @ts-ignore
|
||||||
|
const messageContent = interaction.options.getString("message");
|
||||||
|
|
||||||
const color = getRandomColor();
|
const color = getRandomColor();
|
||||||
const messageId = StoreMan.genId();
|
const messageId = StoreMan.genId();
|
||||||
const userConfessionEmbed = new EmbedBuilder()
|
const userConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`ID ${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.setDescription(`"${interaction.options.getString("message")}"`);
|
.setDescription(messageContent);
|
||||||
|
|
||||||
const adminConfessionEmbed = new EmbedBuilder()
|
const adminConfessionEmbed = new EmbedBuilder()
|
||||||
.setColor(color)
|
.setColor(color)
|
||||||
.setTitle(`Anonymous Confession \`ID ${messageId}\``)
|
.setTitle(`Anonymous Confession \`${messageId}\``)
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.setDescription(`"${interaction.options.getString("message")}"`)
|
.setDescription(messageContent)
|
||||||
.addFields({
|
.addFields({
|
||||||
name: "Author",
|
name: "Author",
|
||||||
value: interaction.user.displayName
|
value: interaction.user.displayName
|
||||||
|
@ -94,7 +96,7 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
embeds: [adminConfessionEmbed]
|
embeds: [adminConfessionEmbed]
|
||||||
});
|
});
|
||||||
|
|
||||||
dt.addConfession(message, messageId, interaction.user.displayName, interaction.user.id);
|
dt.addConfession(message, messageId, interaction.user.displayName, interaction.user.id, messageContent);
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Confession sent!",
|
content: "Confession sent!",
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
* 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, IntegrationApplication, SlashCommandBuilder, TextChannel } from "discord.js";
|
import { 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 Logger from "../utils/Logger";
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
export const data = new SlashCommandBuilder()
|
||||||
.setName("confessdel")
|
.setName("confessdel")
|
||||||
|
@ -41,20 +43,25 @@ export async function execute(interaction: CommandInteraction) {
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const idVal = interaction.options.getString("id");
|
const idVal = interaction.options.getString("id");
|
||||||
|
const result = dt.getConfession(interaction.guild?.id!, idVal);
|
||||||
const result = dt.delConfesssion(
|
|
||||||
interaction,
|
|
||||||
idVal
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
const confession = dt.getConfession(interaction.guild?.id!, idVal)?.messageId;
|
const confession = dt.getConfession(interaction.guild?.id!, idVal)?.messageId;
|
||||||
const channelId = dt.getGuildInfo(interaction.guild?.id!)?.settings.confessChannel!;
|
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(message => {
|
await (BotClient.channels.cache.get(channelId) as TextChannel).messages.fetch(confession!).then(e => {
|
||||||
message.delete();
|
e.edit({
|
||||||
|
embeds: [emptyEmbed]
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dt.delConfesssion(interaction, idVal);
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Confession removed.",
|
content: "Confession removed.",
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
|
|
|
@ -21,6 +21,7 @@ import crypto from "crypto";
|
||||||
import { Confession, GuildData, GuildSettings } from "./types";
|
import { Confession, GuildData, GuildSettings } from "./types";
|
||||||
import { DATA_DIR } from "./config";
|
import { DATA_DIR } from "./config";
|
||||||
import { CommandInteraction, Message } from "discord.js";
|
import { CommandInteraction, Message } from "discord.js";
|
||||||
|
import Logger from "../utils/Logger";
|
||||||
|
|
||||||
export class StoreMan {
|
export class StoreMan {
|
||||||
public static readonly fullPath: string =
|
public static readonly fullPath: string =
|
||||||
|
@ -38,13 +39,14 @@ export class StoreMan {
|
||||||
id: string,
|
id: string,
|
||||||
author: string,
|
author: string,
|
||||||
authorId: string,
|
authorId: 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: message.content.replace(/(# Confession .{4}:\n)/, ""),
|
content: content
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +118,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(message: Message, id: string, author: string, authorId: string): boolean {
|
public addConfession(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) {
|
||||||
|
@ -126,7 +128,7 @@ export class StoreMan {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.confessions.push(StoreMan.toConfession(message, id, author, authorId));
|
guild.confessions.push(StoreMan.toConfession(message, id, author, authorId, content));
|
||||||
this.saveFile();
|
this.saveFile();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -141,6 +143,7 @@ export class StoreMan {
|
||||||
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) {
|
||||||
|
Logger.log(confession);
|
||||||
if (confession.id === confessionId) {
|
if (confession.id === confessionId) {
|
||||||
return confession;
|
return confession;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue