add slash command
This commit is contained in:
parent
fb0c39b5c8
commit
3ef1bccb7a
|
@ -0,0 +1,21 @@
|
|||
global.commands = [
|
||||
{
|
||||
name: "list",
|
||||
description: "Show the members on the other side of an MPP bridge",
|
||||
exec: i => {
|
||||
let bridge = bridges.find(x => x.channel == i.channel.id);
|
||||
if (!bridge) return i.reply({ephemeral: true, content: "Not available in this channel"});
|
||||
let ppl_list = Object.values(bridge.client.ppl).map(m => `\`${m._id}\` ${m.name}`);
|
||||
i.reply({content: `__**${ppl_list.length} people are playing**__\n${ppl_list.join("\n")}`});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
client.on("interactionCreate", interaction => {
|
||||
commands.find(x => x.name == interaction.commandName)?.exec?.(interaction);
|
||||
});
|
||||
|
||||
client.once("ready", () => {
|
||||
client.guilds.resolve(config.guildID)?.commands.set(commands);
|
||||
});
|
16
main.js
16
main.js
|
@ -30,13 +30,13 @@ global.dClient = new Discord.Client({
|
|||
|
||||
dClient.login(config.DISCORD_TOKEN);
|
||||
|
||||
dClient.once('ready', () => {
|
||||
dClient.on('ready', () => {
|
||||
console.log('Discord Client Ready');
|
||||
|
||||
require('./eval-exec');
|
||||
require('./mppbridger');
|
||||
require('./misc');
|
||||
require('./ddpbridge');
|
||||
require('./prbridge');
|
||||
|
||||
});
|
||||
|
||||
require('./eval-exec');
|
||||
require("./commands");
|
||||
require('./mppbridger');
|
||||
require('./misc');
|
||||
require('./ddpbridge');
|
||||
require('./prbridge');
|
|
@ -202,7 +202,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||
|
||||
|
||||
// start
|
||||
(async function () {
|
||||
client.once("ready", async function () {
|
||||
global.bridges = require("./bridges");
|
||||
for (let bridge of bridges) {
|
||||
try {
|
||||
|
@ -211,4 +211,4 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||
handleError(error, JSON.stringify(bridge));
|
||||
}
|
||||
}
|
||||
})();
|
||||
});
|
Loading…
Reference in New Issue