made minor fixed

pull/11/head
TheCodedProf 3 years ago
parent de618c4488
commit 088b1b217a

@ -29,7 +29,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return; if (!interaction.guild) return;
const user = (interaction.options.getMember("user") as GuildMember | null); const user = (interaction.options.getMember("user") as GuildMember | null);
const channel = interaction.channel as GuildChannel; const channel = interaction.channel as GuildChannel;
if (channel.isTextBased()) { if (!channel.isTextBased()) {
return await interaction.reply({ return await interaction.reply({
embeds: [ embeds: [
new EmojiEmbed() new EmojiEmbed()

@ -3,8 +3,6 @@ import { command } from "../../utils/commandRegistration/slashCommandBuilder.js"
const name = "nucleus"; const name = "nucleus";
const description = "Commands relating to Nucleus itself"; const description = "Commands relating to Nucleus itself";
const subcommand = await command(name, description, `nucleus`) const subcommand = await command(name, description, `nucleus`, undefined, undefined, undefined, undefined, true);
const allowedInDMs = true; export { name, description, subcommand as command };
export { name, description, subcommand as command, allowedInDMs };

@ -181,7 +181,7 @@ async function registerCommandHandler() {
} }
async function execute(check: Function | undefined, callback: Function | undefined, data: CommandInteraction) { async function execute(check: Function | undefined, callback: Function | undefined, data: CommandInteraction) {
console.log(client.commands["contextCommands/user/User info"]) // console.log(client.commands["contextCommands/user/User info"])
if (!callback) return; if (!callback) return;
if (check) { if (check) {
let result; let result;

@ -3,6 +3,7 @@ import type Discord from "discord.js";
import { Collection, MongoClient } from "mongodb"; import { Collection, MongoClient } from "mongodb";
import config from "../config/main.js"; import config from "../config/main.js";
import client from "../utils/client.js"; import client from "../utils/client.js";
import * as crypto from "crypto";
const mongoClient = new MongoClient(config.mongoUrl); const mongoClient = new MongoClient(config.mongoUrl);
await mongoClient.connect(); await mongoClient.connect();
@ -133,7 +134,8 @@ interface TranscriptAuthor {
topRole: { topRole: {
color: number; color: number;
badgeURL?: string; badgeURL?: string;
} };
bot: boolean;
} }
interface TranscriptAttachment { interface TranscriptAttachment {
@ -178,7 +180,7 @@ export class Transcript {
async create(transcript: Omit<TranscriptSchema, "code">) { async create(transcript: Omit<TranscriptSchema, "code">) {
let code; let code;
do { do {
code = Math.random().toString(36).substring(2, 16) + Math.random().toString(36).substring(2, 16); code = crypto.randomBytes(64).toString("base64").replace(/=/g, "").replace(/\//g, "_").replace(/\+/g, "-");
} while (await this.transcripts.findOne({ code: code })); } while (await this.transcripts.findOne({ code: code }));
const doc = await this.transcripts.insertOne(Object.assign(transcript, { code: code })); const doc = await this.transcripts.insertOne(Object.assign(transcript, { code: code }));
@ -200,7 +202,9 @@ export class Transcript {
id: member!.user.id, id: member!.user.id,
topRole: { topRole: {
color: member!.roles.highest.color color: member!.roles.highest.color
} },
iconURL: member!.user.displayAvatarURL({ forceStatic: true}),
bot: member!.user.bot
}, },
guild: interaction.guild!.id, guild: interaction.guild!.id,
channel: interaction.channel!.id, channel: interaction.channel!.id,
@ -212,9 +216,12 @@ export class Transcript {
id: interaction.user.id, id: interaction.user.id,
topRole: { topRole: {
color: interactionMember?.roles.highest.color ?? 0x000000 color: interactionMember?.roles.highest.color ?? 0x000000
},
iconURL: interaction.user.displayAvatarURL({ forceStatic: true}),
bot: interaction.user.bot
} }
} }
} if(member.nickname) newOut.for.nickname = member.nickname;
if(interactionMember?.roles.icon) newOut.createdBy.topRole.badgeURL = interactionMember.roles.icon.iconURL()!; if(interactionMember?.roles.icon) newOut.createdBy.topRole.badgeURL = interactionMember.roles.icon.iconURL()!;
messages.reverse().forEach((message) => { messages.reverse().forEach((message) => {
const msg: TranscriptMessage = { const msg: TranscriptMessage = {
@ -225,10 +232,13 @@ export class Transcript {
id: message.author.id, id: message.author.id,
topRole: { topRole: {
color: message.member!.roles.highest.color color: message.member!.roles.highest.color
} },
iconURL: member!.user.displayAvatarURL({ forceStatic: true}),
bot: message.author.bot
}, },
createdTimestamp: message.createdTimestamp 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.content) msg.content = message.content;
if (message.embeds.length > 0) msg.embeds = message.embeds.map(embed => { if (message.embeds.length > 0) msg.embeds = message.embeds.map(embed => {
@ -314,6 +324,7 @@ export class Transcript {
out += `[Attachment] ${attachment.filename} (${attachment.size} bytes) ${attachment.url}\n`; out += `[Attachment] ${attachment.filename} (${attachment.size} bytes) ${attachment.url}\n`;
} }
} }
out += "\n\n"
} }
return out return out
} }

Loading…
Cancel
Save