19 lines
No EOL
574 B
JavaScript
19 lines
No EOL
574 B
JavaScript
const { REST } = require('@discordjs/rest');
|
|
const { Routes } = require('discord-api-types/v9');
|
|
|
|
module.exports = async function(client, commands, guildId){
|
|
const rest = new REST({ version: '9' }).setToken(client.token);
|
|
try {
|
|
var userId = client.id || client.user.id;
|
|
var route = !!guildId ? Routes.applicationGuildCommands(userId, guildId) : Routes.applicationCommands(client.user.id);
|
|
await rest.put(
|
|
route,
|
|
{ body: commands },
|
|
);
|
|
return true;
|
|
|
|
} catch (error) {
|
|
console.error(error);
|
|
return false
|
|
}
|
|
} |