discord.js-slah

1.3.2 • Public • Published

discord.js-slash

A Node.js Discord API for Slash commands

Example-> get All command:

const slashCommndjs = require('discord.js-slah')

const slash = new slashCommndjs.InteractionsClient(process.env.TOKEN, process.env.BOTID)


const allCommands = await slash.getCommands() //returns Array
console.log(allCommands) /// output => [{}]

Example -> create a command

const slashCommndjs = require('discord.js-slah')

const slash = new slashCommndjs.InteractionsClient(process.env.TOKEN, process.env.BOTID)

 // optional
client.slshCommands = new Discord.Collection();

const allCommands = await slash.getCommands()

const commands = [{name:'ping',description:'test the bots response time XD'},{name:'test',description:'test test test'}]

   

 commands.forEach((command)=>{
            const result = allSlashCommands.find(cmd => cmd.name == command.name)
            if (!result)
                await slash.createCommand({ name: command.name, description: command.description })
            
            // optional
            client.slshCommands.set(command.name, commands);

         })

Example-> convert to Message:

const slashCommndjs = require('discord.js-slah')
    client.ws.on('INTERACTION_CREATE', async interaction => {
        // do stuff and respond here

        const message = new slashCommndjs.convertToMessage(client, interaction).handel()
        //before  > interaction.data.name 
        //after > message.content
        
        // reply with interaction
         client.api.interactions(interaction.id,interaction.token).callback.post({
                data: {
                    type: 4,
                    data: {
                        content: 'Hello World !'
                    }
                }
            })
           //reply with message
        if (message.content=='ping')
            message.reply('pong !')
        
    })

Readme

Keywords

none

Package Sidebar

Install

npm i discord.js-slah

Weekly Downloads

0

Version

1.3.2

License

ISC

Unpacked Size

12.3 kB

Total Files

5

Last publish

Collaborators

  • sajjadmrx