mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-09 23:40:18 +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; }) => {
|
||||||
if(!client.application) return;
|
try {
|
||||||
client.application.commands.create({
|
if(!client.application) return;
|
||||||
name: command.name,
|
await client.application.commands.create({
|
||||||
description: command.description,
|
name: command.name,
|
||||||
options: command.options || []
|
description: command.description,
|
||||||
}, guild.id);
|
options: command.options || []
|
||||||
client.funcs.logger('Application Commands', 'Guild: ' + guild.id + " (" + guild.name + ") \n" + 'Command: ' + command.name);
|
}, 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 {
|
} 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; }) => {
|
||||||
if(!client.application) return;
|
try {
|
||||||
client.application.commands.set([], guild.id);
|
if(!client.application) return;
|
||||||
|
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