convert some commands to global commands
This commit is contained in:
19 files changed
+72
-24
No files matched your search
@@ -3,6 +3,7 @@ const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('
|
||||
module.exports = {
|
||||
name: "311",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Report a non emergency",
|
||||
usage: "[name] [service] [location] [nature]",
|
||||
permissions: {
|
||||
|
||||
@@ -3,6 +3,7 @@ const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('
|
||||
module.exports = {
|
||||
name: "911",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Call the emergency hotline",
|
||||
usage: "[name] [service] [location] [nature]",
|
||||
permissions: {
|
||||
|
||||
@@ -5,6 +5,7 @@ const { Inventory, addInventory } = require('../structures/inventory');
|
||||
module.exports = {
|
||||
name: "bank",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Manage your banking",
|
||||
usage: "[cmd] [opt], flags: (1 << 6)",
|
||||
permissions: {
|
||||
|
||||
@@ -4,6 +4,7 @@ const { Bank, addBank } = require('../structures/bank');
|
||||
module.exports = {
|
||||
name: "fine",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Fine a user for an offense",
|
||||
usage: "[user] [amount]",
|
||||
permissions: {
|
||||
|
||||
@@ -4,6 +4,7 @@ const settings = require('../config/settingsHelp');
|
||||
module.exports = {
|
||||
name: "help",
|
||||
debug: false,
|
||||
global: true,
|
||||
description: "Get information on a specific command",
|
||||
usage: "[option]",
|
||||
permissions: {
|
||||
|
||||
@@ -6,6 +6,7 @@ const getActions = ['pick up', 'grab', 'get', 'aquire', 'obtain', 'gain', 'take
|
||||
module.exports = {
|
||||
name: "inventory",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Manage your inventory",
|
||||
usage: "[command]",
|
||||
permissions: {
|
||||
|
||||
@@ -3,6 +3,7 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
name: "me",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Send a message stating your characters action",
|
||||
usage: "[action]",
|
||||
permissions: {
|
||||
|
||||
@@ -4,6 +4,7 @@ const { Bank, addBank } = require('../structures/bank');
|
||||
module.exports = {
|
||||
name: "money",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "add/remove money from user",
|
||||
usage: "[opt.] [user] [amount]",
|
||||
permissions: {
|
||||
|
||||
@@ -3,6 +3,7 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
name: "ping",
|
||||
debug: true,
|
||||
global: true,
|
||||
description: "Test bot activity",
|
||||
usage: "",
|
||||
permissions: {
|
||||
|
||||
@@ -5,6 +5,7 @@ const { addBank } = require('../structures/bank');
|
||||
module.exports = {
|
||||
name: "reset",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Reset a users data",
|
||||
usage: "[user]",
|
||||
permissions: {
|
||||
|
||||
@@ -4,6 +4,7 @@ const { Inventory, addInventory } = require('../structures/inventory');
|
||||
module.exports = {
|
||||
name: "search",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Search a users inventory",
|
||||
usage: "[user]",
|
||||
permissions: {
|
||||
|
||||
@@ -4,6 +4,7 @@ const bitfieldCalculator = require('discord-bitfield-calculator');
|
||||
module.exports = {
|
||||
name: "settings",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Configure your server settings",
|
||||
usage: "[opt] [action] [value]",
|
||||
permissions: {
|
||||
|
||||
@@ -3,6 +3,7 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
name: "stats",
|
||||
debug: true,
|
||||
global: true,
|
||||
description: "check bot statistics",
|
||||
usage: "",
|
||||
permissions: {
|
||||
|
||||
@@ -3,6 +3,7 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
name: "tweet",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Tweet your thoughts to the local twitter page",
|
||||
usage: "[message]",
|
||||
permissions: {
|
||||
|
||||
@@ -3,6 +3,7 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
name: "wallet",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "manage your wallet",
|
||||
usage: "[cmd] [opt]",
|
||||
permissions: {
|
||||
|
||||
@@ -3,6 +3,7 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
name: "work-roles",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "list work roles",
|
||||
usage: "",
|
||||
permissions: {
|
||||
|
||||
@@ -5,6 +5,7 @@ const { Bank, addBank } = require('../structures/bank');
|
||||
module.exports = {
|
||||
name: "work",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "work to earn your income",
|
||||
usage: "",
|
||||
permissions: {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const { RegisterGlobalCommands, RegisterGuildCommands} = require("../util/RegisterSlashCommands");
|
||||
const { Collection, Client, EmbedBuilder, Routes } = require('discord.js');
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const { REST } = require('@discordjs/rest');
|
||||
@@ -132,10 +133,10 @@ class QuarksBot extends Client {
|
||||
Channel.send(embed);
|
||||
}
|
||||
|
||||
// Calls register for guild and global commands
|
||||
RegisterSlashCommands() {
|
||||
this.guilds.cache.forEach((guild) => {
|
||||
require("../util/RegisterSlashCommands")(this, guild.id);
|
||||
});
|
||||
RegisterGlobalCommands(this);
|
||||
this.guilds.cache.forEach((guild) => {RegisterGuildCommands(this, guild.id)});
|
||||
}
|
||||
|
||||
async GetGuild(GuildId) {
|
||||
|
||||
@@ -6,34 +6,64 @@ const { REST } = require('@discordjs/rest');
|
||||
/**
|
||||
* Register slash commands for a guild
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {string} guild
|
||||
*/
|
||||
module.exports = async function(client, guild) {
|
||||
module.exports = {
|
||||
// Register guild commands
|
||||
RegisterGuildCommands: async function(client, guild) {
|
||||
const commands = [];
|
||||
const commandFiles = fs.readdirSync(path.join(__dirname, "..", "commands")).filter(file => file.endsWith('.js'));
|
||||
|
||||
const commands = [];
|
||||
const commandFiles = fs.readdirSync(path.join(__dirname, "..", "commands")).filter(file => file.endsWith('.js'));
|
||||
// Place your client and guild ids here
|
||||
const clientId = client.application.id;
|
||||
const guildId = guild;
|
||||
|
||||
// Place your client and guild ids here
|
||||
const clientId = client.application.id;
|
||||
const guildId = guild;
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`);
|
||||
if (!command.global) commands.push(command);
|
||||
}
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`);
|
||||
commands.push(command);
|
||||
}
|
||||
const rest = new REST({ version: '10' }).setToken(client.config.Token);
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(client.config.Token);
|
||||
try {
|
||||
client.log(`[${guildId}] Started refreshing guild (/) commands.`);
|
||||
|
||||
try {
|
||||
client.log('Started refreshing application (/) commands.');
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(clientId, guildId),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(clientId, guildId),
|
||||
{ body: commands },
|
||||
);
|
||||
client.log(`[${guildId}] Successfully reloaded guild (/) commands.`);
|
||||
} catch (error) {
|
||||
client.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
client.log('Successfully reloaded application (/) commands.');
|
||||
} catch (error) {
|
||||
client.error(error);
|
||||
// Register global commands
|
||||
RegisterGlobalCommands: async function(client) {
|
||||
const commands = [];
|
||||
const commandFiles = fs.readdirSync(path.join(__dirname, "..", "commands")).filter(file => file.endsWith('.js'));
|
||||
|
||||
// Place your client and guild ids here
|
||||
const clientId = client.application.id;
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`);
|
||||
if (command.global) commands.push(command);
|
||||
}
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(client.config.Token);
|
||||
|
||||
try {
|
||||
client.log('[global] Started refreshing global (/) commands.');
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationCommands(clientId),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
client.log('[global] Successfully reloaded global (/) commands.');
|
||||
} catch (error) {
|
||||
client.error(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user