mirror of
https://github.com/DarthKilroy/Spot.git
synced 2025-12-19 18:26:48 +00:00
rewrite
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:
parent
6688d4dcd8
commit
56091a6df7
33 changed files with 731 additions and 1116 deletions
58
model/messages.ts
Normal file
58
model/messages.ts
Normal 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,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue