-
Notifications
You must be signed in to change notification settings - Fork 0
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
58f0673
commit dc544e1
Showing
1 changed file
with
31 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,55 @@ | ||
//do not delete needed for env | ||
require('dotenv').config() | ||
require("dotenv").config(); | ||
|
||
const { Client, GatewayIntentBits } = require('discord.js'); | ||
const { Client, GatewayIntentBits } = require("discord.js"); | ||
const client = new Client({ intents: [GatewayIntentBits.Guilds] }); | ||
|
||
const { REST, Routes } = require('discord.js'); | ||
const clientId = '1017062749538361474'; | ||
const guildId = '1011989055736660061'; | ||
const { REST, Routes } = require("discord.js"); | ||
const clientId = "1017062749538361474"; | ||
const guildId = "1011989055736660061"; | ||
|
||
// slash commands | ||
const commands = [ | ||
{ | ||
name: 'ping', | ||
description: 'Replies with Pong!', | ||
name: "ping", | ||
description: "Replies with Pong!", | ||
}, | ||
{ | ||
name: "help", | ||
description: "help function for bot, lists commands", | ||
}, | ||
]; | ||
|
||
|
||
//register slash commands | ||
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN); | ||
const rest = new REST({ version: "10" }).setToken(process.env.TOKEN); | ||
|
||
(async () => { | ||
try { | ||
console.log('Started refreshing application (/) commands.'); | ||
console.log("Started refreshing application (/) commands."); | ||
|
||
await rest.put(Routes.applicationCommands(clientId), { body: commands }); | ||
|
||
console.log('Successfully reloaded application (/) commands.'); | ||
console.log("Successfully reloaded application (/) commands."); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
})(); | ||
|
||
|
||
// run bot | ||
client.on('ready', () => { | ||
console.log(`Logged in as ${client.user.tag}!`); | ||
}); | ||
|
||
client.on('interactionCreate', async interaction => { | ||
if (!interaction.isChatInputCommand()) return; | ||
|
||
if (interaction.commandName === 'ping') { | ||
await interaction.reply('Pong!'); | ||
} | ||
}) | ||
|
||
client.login(process.env.TOKEN) | ||
client.on("ready", () => { | ||
console.log(`Logged in as ${client.user.tag}!`); | ||
}); | ||
|
||
client.on("interactionCreate", async (interaction) => { | ||
if (!interaction.isChatInputCommand()) return; | ||
|
||
if (interaction.commandName === "ping") { | ||
await interaction.reply("Pong!"); | ||
} | ||
|
||
if (interaction.commandName === "help") { | ||
await interaction.reply("not yet"); | ||
} | ||
}); | ||
|
||
client.login(process.env.TOKEN); |