mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-22 17:03:17 +00:00
Handling missing access to guilds in commands.ts
This commit is contained in:
parent
224a1f849d
commit
7cd00ed645
@ -35,18 +35,22 @@ export default async function commands(client: RadioClient) {
|
||||
for(const command of commands){
|
||||
let guilds = await client.guilds.fetch();
|
||||
guilds.forEach(async (guild: { id: Snowflake; name: string; }) => {
|
||||
try {
|
||||
if(!client.application) return;
|
||||
client.application.commands.create({
|
||||
await client.application.commands.create({
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
options: command.options || []
|
||||
}, guild.id);
|
||||
client.funcs.logger('Application Commands', 'Guild: ' + guild.id + " (" + guild.name + ") \n" + 'Command: ' + command.name);
|
||||
} catch(DiscordAPIError) {
|
||||
client.funcs.logger('Application Commands', 'Guild: ' + guild.id + " (" + guild.name + ") [FAILED] \n" + 'Command: ' + command.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for(const command of commands){
|
||||
client.application.commands.create({
|
||||
await client.application.commands.create({
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
options: command.options || []
|
||||
@ -57,8 +61,11 @@ export default async function commands(client: RadioClient) {
|
||||
|
||||
let guilds = await client.guilds.fetch();
|
||||
guilds.forEach(async (guild: { id: Snowflake; }) => {
|
||||
try {
|
||||
if(!client.application) return;
|
||||
client.application.commands.set([], guild.id);
|
||||
await client.application.commands.set([], guild.id);
|
||||
} catch (DiscordAPIError){
|
||||
}
|
||||
});
|
||||
}
|
||||
client.funcs.logger('Application Commands', 'Successfully reloaded application (/) commands.' + "\n");
|
||||
|
Loading…
Reference in New Issue
Block a user