mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-15 05:36:54 +00:00
Added Slash Command registration timing
This commit is contained in:
+118
-93
@@ -5,109 +5,134 @@ const {Client, Constants} = require('discord.js');
|
|||||||
* @param {Client} bot
|
* @param {Client} bot
|
||||||
*/
|
*/
|
||||||
function registerCommands(bot) {
|
function registerCommands(bot) {
|
||||||
const commands = bot.application.commands;
|
return new Promise((resolve, reject) => {
|
||||||
|
const commands = bot.application.commands;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
val: {
|
val: {
|
||||||
name: 'code',
|
name: 'code',
|
||||||
description: "See where Selmer bot's code is stored! (you can also use _!repo_)",
|
description: "See where Selmer bot's code is stored! (you can also use _!repo_)",
|
||||||
execute: [Function: execute]
|
execute: [Function: execute]
|
||||||
},
|
},
|
||||||
|
|
||||||
key: code
|
key: code
|
||||||
*/
|
*/
|
||||||
bot.commands.forEach((val, key) => {
|
|
||||||
if ((val.options && val.name != 'econ') || val.isDm) {
|
//#region Slash Commands
|
||||||
if (val.isDm) {
|
bot.commands.forEach((val, key) => {
|
||||||
commands.create({
|
if ((val.options && val.name != 'econ') || val.isDm) {
|
||||||
name: val.name,
|
if (val.isDm) {
|
||||||
description: val.description,
|
commands.create({
|
||||||
options: val.options,
|
name: val.name,
|
||||||
dm_permission: true,
|
description: val.description,
|
||||||
});
|
options: val.options,
|
||||||
|
dm_permission: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
commands.create({
|
||||||
|
name: val.name,
|
||||||
|
description: val.description,
|
||||||
|
options: val.options,
|
||||||
|
dm_permission: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
commands.create({
|
// console.log(val, key);
|
||||||
name: val.name,
|
console.log(key);
|
||||||
description: val.description,
|
|
||||||
options: val.options,
|
|
||||||
dm_permission: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
// console.log(val, key);
|
|
||||||
console.log(key);
|
//Create the "econ" commands
|
||||||
|
const econList = ["buy", 'shop', 'work', 'rank', 'inventory', 'balance', 'sell'];
|
||||||
|
const econMain = require('./commands/db/econSlashOptions.js');
|
||||||
|
|
||||||
|
econList.forEach((commandName) => {
|
||||||
|
const command = econMain[`${commandName}`];
|
||||||
|
commands.create({
|
||||||
|
name: commandName,
|
||||||
|
description: command.description,
|
||||||
|
options: command.options || [],
|
||||||
|
dm_permission: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//Create the moderation commands
|
||||||
|
//NOTE: The user needs to have kicking or banning permissions to use these
|
||||||
|
const modList = ['lock', 'unlock', 'kick', 'ban', 'unban', 'mute', 'unmute'];
|
||||||
|
for (let i = 0; i < modList.length; i++) {
|
||||||
|
const opts = [
|
||||||
|
{name: "user", description: `The user to ${modList[i]}`, type: Constants.ApplicationCommandOptionTypes.USER, required: true},
|
||||||
|
{name: "reason", description: "Why?", type: Constants.ApplicationCommandOptionTypes.STRING, required: false}
|
||||||
|
];
|
||||||
|
|
||||||
|
commands.create({
|
||||||
|
name: modList[i],
|
||||||
|
description: `${modList[i]} a user`,
|
||||||
|
options: opts,
|
||||||
|
dm_permission: false,
|
||||||
|
default_member_permissions: 6,
|
||||||
|
});
|
||||||
|
|
||||||
|
// .then((comm) => {
|
||||||
|
// comm.setDefaultMemberPermissions(Discord.PermissionFlagsBits.KickMembers | Discord.PermissionFlagsBits.BanMembers);
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
//Create the "econ" commands
|
//Admin commands (Home Server only)
|
||||||
const econList = ["buy", 'shop', 'work', 'rank', 'inventory', 'balance', 'sell'];
|
const guild = bot.guilds.cache.get(bot.home_server);
|
||||||
const econMain = require('./commands/db/econSlashOptions.js');
|
guild.commands.create({
|
||||||
|
name: "admin",
|
||||||
econList.forEach((commandName) => {
|
description: "admin commands",
|
||||||
const command = econMain[`${commandName}`];
|
// type: Constants.ApplicationCommandOptionTypes.SUB_COMMAND_GROUP,
|
||||||
commands.create({
|
options: [
|
||||||
name: commandName,
|
{
|
||||||
description: command.description,
|
name: "setpresence",
|
||||||
options: command.options || [],
|
description: "Change the bot's presence",
|
||||||
dm_permission: false,
|
type: Constants.ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||||
|
options: [
|
||||||
|
{name: "pres_text", description: "The new presence text", type: Constants.ApplicationCommandOptionTypes.STRING, required: true },
|
||||||
|
{name: "type", description: "The new presence text", type: Constants.ApplicationCommandOptionTypes.STRING, required: true, choices: [
|
||||||
|
{name: "LISTENING", value: "LISTENING"}, {name: "WATCHING", value: "WATCHING"}, {name: "COMPETING", value: "COMPETING"}, {name: "PLAYING", value: "PLAYING"}, { name: "STREAMING", value: "STREAMING"}
|
||||||
|
]},
|
||||||
|
{name: 'display_name', description: "What to display instead of the stream's title", type: Constants.ApplicationCommandOptionTypes.STRING, required: false}
|
||||||
|
],
|
||||||
|
dm_permission: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "setactivity",
|
||||||
|
description: "Change the bot's activity",
|
||||||
|
type: Constants.ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||||
|
options: [
|
||||||
|
{name: "type", description: "The new presence text", type: Constants.ApplicationCommandOptionTypes.STRING, required: true, choices: [
|
||||||
|
{name: "Do Not Disturb", value: "dnd"}, {name: "Idle", value: "idle"}, {name: "invisible", value: "invisible"}, {name: "online", value: "online"}
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
dm_permission: false
|
||||||
|
},
|
||||||
|
]
|
||||||
});
|
});
|
||||||
});
|
return resolve(true);
|
||||||
|
//Takes much longer, so it'll be the benchmark for when the Promise resolves
|
||||||
|
//#region GAMES
|
||||||
//Create the moderation commands
|
const gameOpts = require('./commands/games/gameCommandOptions.js');
|
||||||
//NOTE: The user needs to have kicking or banning permissions to use these
|
|
||||||
const modList = ['lock', 'unlock', 'kick', 'ban', 'unban', 'mute', 'unmute'];
|
|
||||||
for (let i = 0; i < modList.length; i++) {
|
|
||||||
const opts = [
|
|
||||||
{name: "user", description: `The user to ${modList[i]}`, type: Constants.ApplicationCommandOptionTypes.USER, required: true},
|
|
||||||
{name: "reason", description: "Why?", type: Constants.ApplicationCommandOptionTypes.STRING, required: false}
|
|
||||||
];
|
|
||||||
|
|
||||||
commands.create({
|
commands.create({
|
||||||
name: modList[i],
|
name: 'game',
|
||||||
description: `${modList[i]} a user`,
|
description: 'Play one of Selmer Bot\'s games!', //NOT APPLICABLE USING SUB COMMAND GROUPS???
|
||||||
options: opts,
|
// type: Constants.ApplicationCommandOptionTypes.SUB_COMMAND_GROUP,
|
||||||
dm_permission: false,
|
options: gameOpts
|
||||||
default_member_permissions: 6,
|
}).then(() => { resolve(true); }).catch((err) => { reject(err); });
|
||||||
});
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
// .then((comm) => {
|
//#endregion
|
||||||
// comm.setDefaultMemberPermissions(Discord.PermissionFlagsBits.KickMembers | Discord.PermissionFlagsBits.BanMembers);
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
//Admin commands (Home Server only)
|
//#region Context Menus
|
||||||
const guild = bot.guilds.cache.get(bot.home_server);
|
commands.create({
|
||||||
guild.commands.create({
|
name: "Temp",
|
||||||
name: "admin",
|
type: 'USER'
|
||||||
description: "admin commands",
|
});
|
||||||
// type: Constants.ApplicationCommandOptionTypes.SUB_COMMAND_GROUP,
|
//#endregion
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "setpresence",
|
|
||||||
description: "Change the bot's presence",
|
|
||||||
type: Constants.ApplicationCommandOptionTypes.SUB_COMMAND,
|
|
||||||
options: [
|
|
||||||
{name: "pres_text", description: "The new presence text", type: Constants.ApplicationCommandOptionTypes.STRING, required: true },
|
|
||||||
{name: "type", description: "The new presence text", type: Constants.ApplicationCommandOptionTypes.STRING, required: true, choices: [
|
|
||||||
{name: "LISTENING", value: "LISTENING"}, {name: "WATCHING", value: "WATCHING"}, {name: "COMPETING", value: "COMPETING"}, {name: "PLAYING", value: "PLAYING"}, { name: "STREAMING", value: "STREAMING"}
|
|
||||||
]},
|
|
||||||
{name: 'display_name', description: "What to display instead of the stream's title", type: Constants.ApplicationCommandOptionTypes.STRING, required: false}
|
|
||||||
],
|
|
||||||
dm_permission: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "setactivity",
|
|
||||||
description: "Change the bot's activity",
|
|
||||||
type: Constants.ApplicationCommandOptionTypes.SUB_COMMAND,
|
|
||||||
options: [
|
|
||||||
{name: "type", description: "The new presence text", type: Constants.ApplicationCommandOptionTypes.STRING, required: true, choices: [
|
|
||||||
{name: "Do Not Disturb", value: "dnd"}, {name: "Idle", value: "idle"}, {name: "invisible", value: "invisible"}, {name: "online", value: "online"}
|
|
||||||
]},
|
|
||||||
],
|
|
||||||
dm_permission: false
|
|
||||||
},
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user