Discord Bot Builder

Discord Bot Builder

Nedostatek hodnocení
Application Setup and Basic Commands: Step By Step
Vytvořil: Phrogg
A simple guide on how to create your first commands, and getting an understanding of what each block and input/output does.
   
Ocenit
Přidat do oblíbených
Oblíbeno
Odebrat z oblíbených
Creating Your Bot's Discord Application: Step One.
- The first thing to do when creating your bot, is to set its file path. To do this, when you first open DBB, select "Create New Project". From here, it will ask you to create a Bot Folder Path. This can be essentially anywhere, as long as it is easily accessible, but keep in mind it holds all of your bots information, and should not be accessed by anyone you done trust. Personally, i prefer to have a "BOT" folder located in the documents folder under my user sign-on with the rest of my bots inside of it. Regardless, once you've selected where you want your bot to be, create its bot folder name, where asked, and click "Create".

-
- Once you have done this, the next step is to create your Bot's Discord Application. To do this, you need to go to the discord developer portal: https://discord.com/developers/docs/intro and log into your discord account. Once you have done this, Click on "Applications" in the top left. From there, your next step is to Create a New Application in the top right, next to your profile icon.
It will prompt you to create a name for your new Bot. This can be changed later, so you don't have to overthink it.

-
Once you have done this, you should navigate into your new application's "Bot" menu, as seen:
-
And select "Add Bot" .
Now that your Bot has an application, you should scroll down, and enable Presence, Server, and Message Intent for the bot. This way you wont run into future problems with permissions.
-
Now that you have done this, your next step is to scroll back up, and copy your Bot's Token.
Your Bots token is incredibly important and should never be given out, unless you absolutely know it is necessary.
Once it is copied, you should leave the tab running, and enter your Bot's projects folder in DBB, then press Alt+Ctrl+T to enter its token.

-
Your bot is officially alive. In Order to invite your bot to a server, you now need to go back to the Discord Dev portal, and get the bots Application ID from the General Information menu, then return to DBB, and in the top left corner of the screen, click "Bot", then select "Generate Bot Invite" and paste the bots ID. After this is done, you can save the link and use it to invite your bot whenever you should please. Often times it is good to put it in your applications description in the Developer Portal for future use. And if you ever need to change its permission requirements, refer to the "Bot Permissions" table, on the same screen you enabled its Intents earlier, and copy the value it gives you into the place of whatever value is in "permissions=_____" at the end of your invite link.
Creating your first command. Workspace setup and Registering Interactions
- The first thing that any slash command you create will start with is the "Interaction [Event]" block. This block contains the initial command name (For a kick user command you would simply write "/kick".), and house all of the primary outputs for the rest of the command.
If you were to, say, create a "Kick" command, you would first need to make sure the person using this command actually had permission to do so within the server. This means your second block after Interaction [Event] would be the "Get Member Info" block. You would then need to connect its required inputs ("Action" and "Member") to those of the interaction block. This allows the workspace to work from one block to the next, and carries all required data along in the process.
-
-----Next, you'll want to select "Member Permissions [Permissions]" inside of the Get_Member_Info block. This specifies what information the bot needs to gather, regarding the bot. The reason it is specified as [Permissions] is so that when going through the value output of the block, it is recognized as exactly that, and not a message like if it were specified as "[text]". This also applies for when selecting Channel and id values.
Once you have your Member_Permissions block set up, you then need to get a "Check Permissions" block. With this, you'll notice that it has an input titled "Permissions". After connecting this to the "Result" output of the Get_Member_Info block, you will also want to connect the action input/outputs.
-----When this is done, depending on the circumstance, you will select what permissions to check for- in this case, to kick another member. Once this is done You will not that the Check_Permissions Block is an "IF' block. meaning it has two separate outputs- "If True" and "If False", meaning if the user has permission to kick another user or not. Starting with the "If True" output, the next step in the command would be to get the interaction argument values. These are what is specified in a command, such as with a music bot, when you specify what song to play, or in our case, mention a user to kick. This said, you want to get the "Get Interaction Argument Value" block. Once you have the action input connected to the previous output, you want the bot to know what arguments its getting. Therefor, you should connect the "Arguments input to the corresponding output on the original Interaction_Event block. In this case you'll only be looking for one user to kick at a time, and nothing else, so the "Argument Number" should be set to 1 (one). Speaking of who to kick, now you need to find the member. This means getting the "Find Member" block, and connecting its inputs to the required outputs, in this case, it needs to know *where* to search, being the server input to that output of the Interaction_Block, and connecting the Value output of the Find_Member block to the "Search Value" input. This lets the bot know *who* its looking for.

-----To keep things simple, you can set the method of searching to "Member_ID" in the "Find_Member" block. This means that when you want to select who to kick from your server, you simply copy paste that members "User ID" into your search argument box, which we'll talk more on later. Now comes the whole reason your doing this, kicking the specified member. To do this, you obviously want to get a "Kick_Member" block, and connect its corresponding inputs. Now, if you want to be fancy, and show a log of who was kicked, when, and by who, in the same channel, you should follow the next few steps. If not, just skip to the next sub-paragraph marked with "-----". If your still reading here, congrats, your making a perfect kick command, seen through to the finish. The next thing you'll want to do is get information about who performed the command. To do this, you need another "Get Member Info" block like from the beginning, and connect it to the same outputs as the first one, on the Interaction_Event block., but with the action input connected the the output of the Kick_Member block. Now that you know *who* performed the command, you need a way for the bot to show it to everyone else. To do this, you should get a "Merge Texts [Advanced]" block (You can easily get this block from the community discord.). With this, you'll next need to connect the output of the Get_Member_Info block, to the "Text 2" input slot. And if you remember the "Value" output of the Interaction_Argument _Value block from earlier, you'll want to also connect it to the "Text 1" input of the Merge_Texts block. Finally, inside of the text box, you will want to type
" **${text1} Has been kicked from the server by ${text2}.** " . The purpose in entering "${text1}" and 2, is to show the values from the text inputs, being who was kicked, and who kicked them. Once you've finished that,
----- Get a "Interaction Reply Block" and connect its required inputs to the respective outputs. If you took the long route and did the above steps, you should connect the text input to that of the Merge_Texts output. If you want everyone to see that this action has been performed, switch
"Is Empheral" to "No". But if you'd rather keep it private, simply leave it on "Yes".

-----Now that the "If True" part is complete, next is to do the "If False" section.
All that'd needed for this, is to create a Text block, that states an error message to tell the user they do not have permission to kick another user, that could go something like this:
" **You do not have permission to kick other members.** ".
Once you've entered that, you need to create another Interaction_Reply_Block, and connect its required inputs to their respective outputs. And The command is Done! Accept its not.

The final thing needed, is a "Register Slash Commands" block. This is what brings the command to life, and makes it show up through discord.
If you've followed along well, all you should have to do in this block is copy paste:
"
[
{
"name": "kick",
"description": "kicks the mentioned user",
"options": [
{
"type": 6,
"name": "mention",
"description": "Enter member to be kicked",
"required": true
}
]
}
]
"
A good tool for creating this code is "Discord Slash Command Builder"
https://autocode.com/tools/discord/command-builder/
This step is required for all slash commands that you create, and each of these segments can be put into the same "Register Slash Commands" block, so long as you follow a few rules:

At the very beginning of the block, write "["
and skip a line before entering the code for the next command which starts at the first "{" and ends at the last "}" .
------
Always seperate commands with a "," at the end of each.
------
Keep a close bracket "]" at the end of the list of commands.
------------------------------------------------------------------------------

An example of the above rules is shown like this:
[
{
"name": "kick",
"description": "kicks the mentioned user",
"options": [
{
"type": 6,
"name": "mention",
"description": "Enter member to be kicked",
"required": true
}
]
},
{
"name": "delete_messages",
"description": "Delete a specified amount of messages.",
"options": [
{
"type": 10,
"name": "amount",
"description": "This is how many messages will be deleted.",
"required": true
}
]
}
]

And there you have it. You've created your first functional command in DBB.
If you've followed along perfectly, your workspace should look something like this:
.
Improvement.
This guide is not done. i Am continually working on this, and improving it as i learn about it, myself.
For any questions regarding DBB, the Discord Dev Portal, or recommendations on how i can improve the guide please feel free to DM me here, or on discord at Phrogg#1247. o7