From 3621bf9afeff5179fa5cc11988054c6500800e6d Mon Sep 17 00:00:00 2001 From: Samuel Shuert Date: Sat, 4 Mar 2023 13:55:40 -0500 Subject: [PATCH] Development (#13) Co-authored-by: PineaFan Co-authored-by: pineafan Co-authored-by: PineappleFan Co-authored-by: Skyler --- src/commands/mod/purge.ts | 1 - src/commands/privacy.ts | 1 - src/config/main.d.ts | 4 +--- src/context/messages/purgeto.ts | 2 -- src/premium/createTranscript.ts | 4 ---- src/utils/database.ts | 13 ++----------- src/utils/log.ts | 3 +++ 7 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts index 004f5ff..a1b094e 100644 --- a/src/commands/mod/purge.ts +++ b/src/commands/mod/purge.ts @@ -330,7 +330,6 @@ const callback = async (interaction: CommandInteraction): Promise => { ], components: [ new Discord.ActionRowBuilder().addComponents([ - new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`).setDisabled(!code), ]) diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts index dcdebb1..69c8980 100644 --- a/src/commands/privacy.ts +++ b/src/commands/privacy.ts @@ -183,7 +183,6 @@ const callback = async (interaction: CommandInteraction): Promise => { await client.database.history.delete(interaction.guild!.id); await client.database.notes.delete(interaction.guild!.id); await client.database.transcripts.deleteAll(interaction.guild!.id); - nextFooter = "All data cleared"; continue; } else { diff --git a/src/config/main.d.ts b/src/config/main.d.ts index 6549234..75eb9e0 100644 --- a/src/config/main.d.ts +++ b/src/config/main.d.ts @@ -15,11 +15,9 @@ declare const config: { password: string, database: string, host: string, + authSource: string }, baseUrl: string, - pastebinApiKey: string, - pastebinUsername: string, - pastebinPassword: string, rapidApiKey: string }; diff --git a/src/context/messages/purgeto.ts b/src/context/messages/purgeto.ts index 616b085..3d7e95a 100644 --- a/src/context/messages/purgeto.ts +++ b/src/context/messages/purgeto.ts @@ -206,9 +206,7 @@ const callback = async (interaction: MessageContextMenuCommandInteraction) => { ], components: [ new Discord.ActionRowBuilder().addComponents([ - new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`).setDisabled(!code), - ]) ] }); diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts index dd01a98..fa5ec84 100644 --- a/src/premium/createTranscript.ts +++ b/src/premium/createTranscript.ts @@ -60,9 +60,7 @@ export default async function (interaction: CommandInteraction | MessageComponen const newOut = await client.database.transcripts.createTranscript(messages, interaction, member); - const [code, key, iv] = await client.database.transcripts.create(newOut); - if(!code) return await interaction.reply({ embeds: [ new EmojiEmbed() @@ -88,9 +86,7 @@ export default async function (interaction: CommandInteraction | MessageComponen ], components: [ new ActionRowBuilder().addComponents([ - new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://testing.coded.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`), - new ButtonBuilder() .setLabel("Delete") .setStyle(ButtonStyle.Danger) diff --git a/src/utils/database.ts b/src/utils/database.ts index 06c41f0..67c1c5f 100644 --- a/src/utils/database.ts +++ b/src/utils/database.ts @@ -6,22 +6,14 @@ import client from "../utils/client.js"; import * as crypto from "crypto"; import _ from "lodash"; import defaultData from '../config/default.js'; -// config.mongoOptions.host, { -// auth: { -// username: config.mongoOptions.username, -// password: config.mongoOptions.password -// }, -// authSource: config.mongoOptions.authSource -// } -// mongodb://emails:SweetLife2023!!@127.0.0.1:28180/saveEmail?retryWrites=true&w=majority + const username = encodeURIComponent(config.mongoOptions.username); const password = encodeURIComponent(config.mongoOptions.password); -const mongoClient = new MongoClient(username ? `mongodb://${username}:${password}@${config.mongoOptions.host}` : `mongodb://${config.mongoOptions.host}`, {authSource: "admin"}); +const mongoClient = new MongoClient(username ? `mongodb://${username}:${password}@${config.mongoOptions.host}?authMechanism=DEFAULT` : `mongodb://${config.mongoOptions.host}`, {authSource: "admin"}); await mongoClient.connect(); const database = mongoClient.db(); const collectionOptions = { authdb: "admin" }; - const getIV = () => crypto.randomBytes(16); @@ -542,7 +534,6 @@ export class Premium { const entry = await this.premium.findOne({ user: user }); return entry ? true : false; } - async createUser(user: string, level: number) { // console.log("Premium createUser"); await this.premium.insertOne({ user: user, appliesTo: [], level: level }, collectionOptions); diff --git a/src/utils/log.ts b/src/utils/log.ts index c6416a1..bb95eda 100644 --- a/src/utils/log.ts +++ b/src/utils/log.ts @@ -79,7 +79,10 @@ export const Logger = { }, async log(log: LoggerOptions): Promise { if (!await isLogging(log.hidden.guild, log.meta.calculateType)) return; + console.log(log.hidden.guild) const config = await client.database.guilds.read(log.hidden.guild); + console.log(config.logging.logs.channel) + if (config.logging.logs.channel) { const channel = (await client.channels.fetch(config.logging.logs.channel)) as Discord.TextChannel | null; const description: Record = {};