this is a rewrite of the bot in typescript. detritus is used as a discord library instead of discord.js
This commit is contained in:
spiral 2022-10-21 17:22:01 +00:00
parent 6688d4dcd8
commit 56091a6df7
No known key found for this signature in database
GPG key ID: 244A11E4B0BCF40E
33 changed files with 731 additions and 1116 deletions

58
model/messages.ts Normal file
View file

@ -0,0 +1,58 @@
import { restClient } from "../bot";
interface Message {
names: string[];
description: string;
title: string;
text: string;
friendlyName: string;
category: string;
}
export const messages: Record<string, Message> = {};
let avatarUrl = "";
const load = async () =>
{
const messagesList = require('../messages.json')["faq"];
messagesList.forEach((msg: any) => {
messages[msg["title"]] = msg
})
const userInfo = await restClient.fetchMe();
avatarUrl = `https://cdn.discordapp.com/avatars/${userInfo.id}/${userInfo.avatar}.png`;
console.log(avatarUrl);
}
load();
export const get = (name: string) => messages[name];
export const getList = () => Object.keys(messages).map(msg => ({ name: messages[msg].names[0], value: messages[msg].description }));
export const getEmbed = (name: string) => {
let foundMsg: Message | undefined;
Object.keys(messages).forEach((msgKey) =>
{
if (foundMsg) return;
const msg = messages[msgKey]
if (msg.names.includes(name))
{
foundMsg = msg;
return;
}
});
if (foundMsg == null) return;
return {
color: 0xA95B44,
author: {
name: foundMsg.title,
iconUrl: avatarUrl,
},
description: foundMsg.text,
}
}