Fix transcript encryption and endpoints
diff --git a/src/commands/nucleus/premium.ts b/src/commands/nucleus/premium.ts
index 0b0f553..58b51a9 100644
--- a/src/commands/nucleus/premium.ts
+++ b/src/commands/nucleus/premium.ts
@@ -193,7 +193,7 @@
);
}
- let userPremiumServers;
+ let userPremiumServers = "";
if ((dbMember?.appliesTo.length ?? 0) > 0) userPremiumServers = "\nIf you want to remove premium from a server, run this command in your DMs with me.";
interaction.editReply({
diff --git a/src/utils/database.ts b/src/utils/database.ts
index 8f37466..c46a39d 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -251,7 +251,8 @@
.replace(/\//g, "_")
.replace(/\+/g, "-")
.substring(0, 32);
- const iv = getIV().toString("base64").replace(/=/g, "").replace(/\//g, "_").replace(/\+/g, "-");
+ const iv = getIV().toString("base64").substring(0, 16).replace(/=/g, "").replace(/\//g, "_").replace(/\+/g, "-");
+ console.log(iv);
for (const message of transcript.messages) {
if (message.content) {
const encCipher = crypto.createCipheriv("AES-256-CBC", key, iv);
@@ -320,9 +321,10 @@
}
async read(code: string, key: string, iv: string) {
- // console.log("Transcript read")
+ console.log("Transcript read")
let doc: TranscriptSchema | null = await this.transcripts.findOne({ code: code });
let findDoc: findDocSchema | null = null;
+ console.log(doc)
if (!doc) findDoc = await this.messageToTranscript.findOne({ transcript: code });
if (findDoc) {
const message = await (
@@ -348,6 +350,7 @@
if (!data) return null;
doc = JSON.parse(Buffer.from(data).toString()) as TranscriptSchema;
}
+ console.log(doc)
if (!doc) return null;
for (const message of doc.messages) {
if (message.content) {
@@ -401,15 +404,15 @@
discriminator: parseInt(message.author.discriminator),
id: message.author.id,
topRole: {
- color: message.member!.roles.highest.color
+ color: message.member ? message.member.roles.highest.color : 0x000000
},
- iconURL: message.member!.user.displayAvatarURL({ forceStatic: true }),
- bot: message.author.bot
+ iconURL: (message.member?.user || message.author)?.displayAvatarURL({ forceStatic: true }),
+ bot: message.author?.bot || false
},
createdTimestamp: message.createdTimestamp
};
if (message.member?.nickname) msg.author.nickname = message.member.nickname;
- if (message.member!.roles.icon) msg.author.topRole.badgeURL = message.member!.roles.icon.iconURL()!;
+ if (message.member?.roles.icon) msg.author.topRole.badgeURL = message.member!.roles.icon.iconURL()!;
if (message.content) msg.content = message.content;
if (message.embeds.length > 0)
msg.embeds = message.embeds.map((embed) => {