Skip to content

Instantly share code, notes, and snippets.

View rohank05's full-sized avatar
🎯
Chilling

Rohan Kumar rohank05

🎯
Chilling
View GitHub Profile
@rohank05
rohank05 / discordjs-slash-commands.md
Created December 17, 2020 05:28 — forked from advaith1/discordjs-slash-commands.md
Slash Commands in Discord.js

Slash Commands in Discord.js

These are some simple examples for using Slash Commands in discord.js.
discord.js doesn't have full support for slash commands yet (there's a wip pr) but you can still use the underlying api and websocket to use them.
Note that discord.js doesn't officially support using client.api, this is basically just a workaround until they fully release support.

Please read Discord's Slash Command docs since they have actual docs and details for slash commands; the code examples below are just how you can implement it using discord.js.

Note that slash commands won't show in a server unless that server has authorized it with the applications.commands oauth2 scope (not just the bot scope).

const Discord = require('discord.js');
const client = new Discord.Client();
const prefix= '=';
const guildID = '';
const token = '';
var ques;