command

Making commands

  • For making a command first make a folder commands/

  • now in the folder, make a file! Example: ping.js

  • now add this codes in it!

Making commands!

module.exports = {
    name: 'ping',
    description: 'Shows latency ping!',
    options: [],
    run: async({ interaction, client, args, reply, editReply }) => {
        let r = await reply({ content: "hi" + interaction.member }) //interaction will be slash interaction when user uses slash command but if users uses normal then interaction will me message!
    }
}

Arguments in command!

module.exports = {
    name: 'say',
    description: 'Shows latency ping!',
    options: [{
        name: 'input',
        type: 'STRING',
        description: 'The input to echo back',
        required: true,
    }],
    run: async({ interaction, client, args, reply, editReply }) => {
        let r = await reply({ content: "hi" + interaction.member }) //interaction will be slash interaction when user uses slash command but if users uses normal then interaction will me message!
        await editReply(r, { content: "hello"})
    }
}

All types of arguments

STRING
INTEGER
BOOLEAN
USER
CHANNEL
ROLE
MENTIONABLE
SUB_COMMAND_GROUP
SUB_COMMAND

context menu

module.exports = {
    name: 'ping',
    description: 'Shows latency ping!',
    options: [],
    type: "MESSAGE", //USER if you want it to stay as slash command remove type: "",
    run: async({ interaction, client, args, reply, editReply }) => {
        let r = await reply({ content: "hi" + interaction.member }) //interaction will be slash interaction when user uses slash command but if users uses normal then interaction will me message!
    }
}

user Permissions

module.exports = {
    name: 'say',
    description: 'Shows latency ping!',
    userRequiredPermissions: "ADMINISTRATOR", //["ADMINISTRATOR","MANAGE_GUILD"]
    options: [{
        name: 'input',
        type: 'STRING',
        description: 'The input to echo back',
        required: true,
    }],
    run: async({ interaction, client, args, reply, editReply }) => {
        let r = await reply({ content: "hi" + interaction.member }) //interaction will be slash interaction when user uses slash command but if users uses normal then interaction will me message!
        await editReply(r, { content: "hello"})
    }
}

client Permissions

module.exports = {
    name: 'say',
    description: 'Shows latency ping!',
    clientRequiredPermissions: "SEND_MESSAGES",
    options: [{
        name: 'input',
        type: 'STRING',
        description: 'The input to echo back',
        required: true,
    }],
    run: async({ interaction, client, args, reply, editReply }) => {
        let r = await reply({ content: "hi" + interaction.member }) //interaction will be slash interaction when user uses slash command but if users uses normal then interaction will me message!
        await editReply(r, { content: "hello"})
    }
}

bot owner only

module.exports = {
    name: 'say',
    description: 'Shows latency ping!',
    ownerOnly: true, //go to main file and where you have constructed discord-cmds.js add ownerID: ""
    options: [{
        name: 'input',
        type: 'STRING',
        description: 'The input to echo back',
        required: true,
    }],
    run: async({ interaction, client, args, reply, editReply }) => {
        let r = await reply({ content: "hi" + interaction.member }) //interaction will be slash interaction when user uses slash command but if users uses normal then interaction will me message!
        await editReply(r, { content: "hello"})
    }
}

Last updated