-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6856e0e
commit f1396f3
Showing
3 changed files
with
72 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
name: "interactionCreate", | ||
once: true, | ||
async execute(interaction) { | ||
if (!interaction.isCommand()) return; | ||
|
||
const command = interaction.client.commands.get(interaction.commandName); | ||
|
||
if (!command) return; | ||
|
||
try { | ||
await command.execute(interaction); | ||
} catch (err) { | ||
if (err) console.error(err); | ||
|
||
await interaction.reply({ | ||
content: "An error occurred while executing that command.", | ||
ephemeral: true, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { REST } = require("@discordjs/rest"); | ||
const { Routes } = require("discord-api-types/v9"); | ||
require("dotenv").config(); | ||
|
||
module.exports = { | ||
name: "ready", | ||
once: true, | ||
execute(client, commands) { | ||
console.log("Ghost is online."); | ||
|
||
const CLIENT_ID = client.user.id; | ||
|
||
const rest = new REST({ | ||
version: "9", | ||
}).setToken(process.env.TOKEN); | ||
|
||
(async () => { | ||
try { | ||
if (process.env.ENV === "production") { | ||
await rest.put(Routes.applicationCommands(CLIENT_ID), { | ||
body: commands, | ||
}); | ||
console.log("Successfully registered commands globally."); | ||
} else { | ||
await rest.put( | ||
Routes.applicationGuildCommands(CLIENT_ID, process.env.GUILD_ID), | ||
{ | ||
body: commands, | ||
} | ||
); | ||
console.log("Successfully registered commands locally."); | ||
} | ||
} catch (err) { | ||
if (err) console.error(err); | ||
} | ||
})(); | ||
}, | ||
}; |