mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-22 22:13:16 +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){
|
for(const command of commands){
|
||||||
let guilds = await client.guilds.fetch();
|
let guilds = await client.guilds.fetch();
|
||||||
guilds.forEach(async (guild: { id: Snowflake; name: string; }) => {
|
guilds.forEach(async (guild: { id: Snowflake; name: string; }) => {
|
||||||
|
try {
|
||||||
if(!client.application) return;
|
if(!client.application) return;
|
||||||
client.application.commands.create({
|
await client.application.commands.create({
|
||||||
name: command.name,
|
name: command.name,
|
||||||
description: command.description,
|
description: command.description,
|
||||||
options: command.options || []
|
options: command.options || []
|
||||||
}, guild.id);
|
}, guild.id);
|
||||||
client.funcs.logger('Application Commands', 'Guild: ' + guild.id + " (" + guild.name + ") \n" + 'Command: ' + command.name);
|
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 {
|
} else {
|
||||||
for(const command of commands){
|
for(const command of commands){
|
||||||
client.application.commands.create({
|
await client.application.commands.create({
|
||||||
name: command.name,
|
name: command.name,
|
||||||
description: command.description,
|
description: command.description,
|
||||||
options: command.options || []
|
options: command.options || []
|
||||||
@ -57,8 +61,11 @@ export default async function commands(client: RadioClient) {
|
|||||||
|
|
||||||
let guilds = await client.guilds.fetch();
|
let guilds = await client.guilds.fetch();
|
||||||
guilds.forEach(async (guild: { id: Snowflake; }) => {
|
guilds.forEach(async (guild: { id: Snowflake; }) => {
|
||||||
|
try {
|
||||||
if(!client.application) return;
|
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");
|
client.funcs.logger('Application Commands', 'Successfully reloaded application (/) commands.' + "\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user