Creating your First Assigner - TimmyRB/SydneyBot GitHub Wiki

Make sure to follow the instructions on How to Create a Command before continuing.

First, let's add the Assigner import to our existing Command import

import { Command, Assigner } from "../../lib/models/bot";

Next, we'll create an Assigner in our Command's callback

callback: (msg, args, dbUser) => {
    let assigner = new Assigner({
        title: 'Test Assigner',
        description: 'Test Assigner Desc',
        reactionRoles: []
    })  
}
  • title - A title used on the Assigner's Embed
  • description - A description used on the Assigner's Embed
  • reactionRoles - An array of ReactionRoles that can be assigned from a Reaction
    • groupId - Roles of the same GroupId will override each other, groupId of 0 will overwrite every other group
    • name - Name of role shown in Embed
    • emoji - Emoji that will assign role when reacted to
    • roleId - Id of the Role to assign to the react user

Now let's add some roles for our Assigner to assign & run the .show() function to have our Assigner outputted to a channel

callback: (msg, args, dbUser) => {
    let assigner = new Assigner({
        title: 'Test Assigner',
        description: 'Test Assigner Desc',
        reactionRoles: [
            {
                groupId: 0,
                name: 'Role1',
                emoji: '1️⃣',
                roleId: '803857268868251661'
            },
            {
                groupId: 1,
                name: 'Role2',
                emoji: '12️⃣',
                roleId: '803857268868251662'
             },
             {
                groupId: 1,
                name: 'Role3',
                emoji: '3️⃣',
                roleId: '803857268868251663'
            },
            {
                groupId: 2,
                name: 'Role4',
                emoji: '4️⃣',
                roleId: '803857268868251664'
            },
            {
                groupId: 2,
                name: 'Role5',
                emoji: '5️⃣',
                roleId: '803857268868251665'
            }
        ]
    })
        
    assigner.show(msg.channel, msg.author.id)
}

Now when we send the Command, the Bot sends an Embed and reacts to it. Clicking on one of these reactions will change the user's role!