mirror of
https://github.com/DarthKilroy/Spot.git
synced 2025-12-24 20:56:48 +00:00
Update help command to use buttons & text input
also, move messages / "custom commands" to JSON file
This commit is contained in:
parent
c096deb1d0
commit
a4892d854b
18 changed files with 396 additions and 691 deletions
54
model/messages.js
Normal file
54
model/messages.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
let names = {};
|
||||
let messages = {};
|
||||
|
||||
const genRandomId = () => Math.ceil(Math.random() * 1000);
|
||||
|
||||
const load = () => require("../messages").forEach(msg => {
|
||||
let id = genRandomId();
|
||||
while (messages[id])
|
||||
id = genRandomId();
|
||||
|
||||
msg.names.forEach(name => names[name] = id);
|
||||
messages[id] = msg;
|
||||
});
|
||||
|
||||
load();
|
||||
|
||||
// interface Message {
|
||||
// names string[];
|
||||
// description string;
|
||||
// title string;
|
||||
// text string;
|
||||
// }
|
||||
|
||||
const { MessageEmbed } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
get names() {
|
||||
return names;
|
||||
},
|
||||
get messages() {
|
||||
return messages;
|
||||
},
|
||||
get: (name) => messages[names[name]],
|
||||
getList: () => Object.keys(messages).map(msg => ({ name: messages[msg].names[0], value: messages[msg].description })),
|
||||
getEmbed: (name) => {
|
||||
let msg = messages[names[name]];
|
||||
if (!msg) return;
|
||||
|
||||
return {
|
||||
color: APP_MAIN_COLOUR,
|
||||
author: {
|
||||
name: msg.title,
|
||||
iconURL: bot.user.displayAvatarURL({ dynamic: true }),
|
||||
},
|
||||
description: msg.text,
|
||||
}
|
||||
},
|
||||
reload: () => {
|
||||
names = {};
|
||||
messages = {};
|
||||
delete require.cache[require.resolve("../messages")];
|
||||
load();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue