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