Example Bot

This example bot is a good start to creating your own bot! The comments explains the functions!

// define libraries
let { Client, commandsBuilder, Commands, SlashCommandOperations } = require('@pro/diswrap.js');

// define and initiates the bot client
let client = new Client({ token: process.env.DISCORD_TOKEN, supportGuildId: "1059930706643525662" });

// Create a coinflip definition for our custom commands
let coin = new commandsBuilder("coin", "Flip a coin!").build();

// Register the template commands
client.commandsCreate(Commands['8ball'])
client.commandsCreate(Commands.dice)
client.commandsCreate(Commands.ping)
client.commandsCreate(Commands.server)

// Create a custom command for the coin flip
client.customCommandsCreate(coin, async (interaction) => {
    let result = Math.floor(Math.random() * 2) == 0 ? "Heads" : "Tails";
    await interaction.reply(result);
})

// When the client is ready
client.onEventRun('ready', () => {
    // Set the bot's status
    client.client.user.setPresence({ activities: [{ name: 'with @pro/diswrap.js' }], status: 'dnd' })
    
    // Uncomment the line below to deploy all commands to the Discord API
    // client.publishCommand(SlashCommandOperations.deployAll)

    // notifies us that bot is online
    console.log("Logged in as " + client.client.user.tag + "!")
})

Last updated