commit
0f6851adf8
2 changed files with 12 additions and 13 deletions
|
@ -26,8 +26,7 @@ module.exports = {
|
||||||
|
|
||||||
args.forEach(async (arg) => {
|
args.forEach(async (arg) => {
|
||||||
const commandName = arg?.toLowerCase();
|
const commandName = arg?.toLowerCase();
|
||||||
const command = client.commands.get(commandName) ||
|
const command = client.commands.get(commandName);
|
||||||
client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
returnMessage += `There is no command with name or alias \`${commandName}\`\n`;
|
returnMessage += `There is no command with name or alias \`${commandName}\`\n`;
|
||||||
|
|
22
start.js
22
start.js
|
@ -35,34 +35,34 @@ client.once('ready', async () => {
|
||||||
const sandboxSettings = config.sandbox;
|
const sandboxSettings = config.sandbox;
|
||||||
const localCommands = client.guilds.cache.get(sandboxSettings.id)?.commands;
|
const localCommands = client.guilds.cache.get(sandboxSettings.id)?.commands;
|
||||||
const globalCommands = client.application.commands;
|
const globalCommands = client.application.commands;
|
||||||
let existingLocal = await localCommands.fetch();
|
let existingLocal = await localCommands?.fetch();
|
||||||
let existingGlobal = await globalCommands.fetch();
|
let existingGlobal = await globalCommands?.fetch();
|
||||||
|
|
||||||
if (sandboxSettings.enabled) {
|
if (sandboxSettings.enabled) {
|
||||||
if (sandboxSettings.refreshLocal) {
|
if (sandboxSettings.refreshLocal) {
|
||||||
console.log('deleting previous local commands');
|
console.log('deleting previous local commands');
|
||||||
existingLocal.forEach(async x => {
|
existingLocal?.forEach(async x => {
|
||||||
await localCommands.delete(x);
|
await localCommands?.delete(x);
|
||||||
});
|
});
|
||||||
existingLocal = new Discord.Collection();
|
existingLocal = new Discord.Collection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sandboxSettings.refreshGlobal) {
|
if (sandboxSettings.refreshGlobal) {
|
||||||
console.log('deleting previous global commands');
|
console.log('deleting previous global commands');
|
||||||
existingGlobal.forEach(async x => {
|
existingGlobal?.forEach(async x => {
|
||||||
await client.application.commands.delete(x);
|
await client.application?.commands.delete(x);
|
||||||
});
|
});
|
||||||
existingGlobal = new Discord.Collection();
|
existingGlobal = new Discord.Collection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.commands.forEach(async command => {
|
client.commands.forEach(async command => {
|
||||||
if (sandboxSettings.enabled && !existingLocal.map(x => x.name).includes(command.name)) {
|
if (sandboxSettings.enabled && !existingLocal?.map(x => x.name).includes(command.name)) {
|
||||||
await localCommands.create(command);
|
await localCommands?.create(command);
|
||||||
// console.log(`created new local command ${command.name}`);
|
// console.log(`created new local command ${command.name}`);
|
||||||
}
|
}
|
||||||
if (!existingGlobal.map(x => x.name).includes(command.name)) {
|
if (!existingGlobal?.map(x => x.name).includes(command.name)) {
|
||||||
await globalCommands.create(command);
|
await globalCommands?.create(command);
|
||||||
// console.log(`created new global command ${command.name}`);
|
// console.log(`created new global command ${command.name}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -79,7 +79,7 @@ client.once('ready', async () => {
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
// Picks a status from the config file
|
// Picks a status from the config file
|
||||||
const index = Math.floor(Math.random() * config.statuses.length);
|
const index = Math.floor(Math.random() * config.statuses.length);
|
||||||
await client.user.setActivity(config.statuses[index]);
|
await client.user?.setActivity(config.statuses[index]);
|
||||||
}, 20000);
|
}, 20000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Reference in a new issue