Repository
https://github.com/adsau59/supbot
What Will I Learn?
- What is Command in Supbot API?
- What is Feature in Supbot API?
- How to create Command using Supbot API?
Requirements
Required Knowledge
- Java
Difficulty
Basic
✔Intermediate
Advanced
Description
In this Supbot API tutorial, we will understand what is Command
and Feature
and why it is used. We will then create a custom command that shows meaning of a term using Urban Dictionary REST API.
Commands
Commands are the functions that can be called by a client. So, the clients can use command to tell the bot what to do. When a client writes a command in a group, Supbot reads the command and performs actions depending on the command client used, arguments the client passed, and the client themself.
To create a command, create a class and extend it with Command
class and then implement its abstract methods and override its Constructor.
When a command is called, the compute
method is called.
getHelper
method is used when the client uses help commands, which explains them how the command should work.
Features
Feature encapsulates many commands into one group. For example, if we want to make voting in our bot, there will be commands like, start-vote, vote, end-vote, show-vote-results so we can group all these commands into one group called Voting.
To create a feature, create a class and extend it with Feature
calss and then implement its abstract methods and override its Constructor.
getDescription
simply returns a string which says what is the purpose of the feature, it is shown when the help-feature command is used.
How to add it in the Supbot?
So to add your own command to the bot, you will have to first Create the Command
Then Create the feature, and put the command in its constructor parameter
Then finally add the feature to the bot, using Bot.getFeatureManager().add()
function, in the addThingsInBot method in the main class
Thank you for your contribution @adam-saudagar,
I can see great improvement in this tutorial as you put effort to make the changes from the last 2 tutorials.
You have also put in the effort to create some caption slides so that people can follow your teaching easier
I know it is difficult for people whose English is their second language, so English is something you need to work on. I can hear that you have been more careful with your diction and in your expressions.
What you may not be aware of is that English has phrasing. Many languages do as well but phrasing in English is very important to make your speech to flow. I know that you are wanting to do a series of tutorials on this subject, so you can work on your phrasing as you teach in these tutorials. English words do not sound good one by one. They don't flow. So what you need to do is to find the right pauses between a group of words and that is how you phrase. You can listen to some of my tutorials. I don't go: da da da da da ..... like this. I go: dadadada dadada dadadad.
It is like singing. You don't sing words. You sing phrases to communicate an idea.
I hope this is helpful to you but I want to congratulate you for putting in the effort to make this tutorial more pleasant for learners.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thanks for the review, will work on my English skills
I love that you give genuine criticism <3
Hey @rosatravels
Here's a tip for your valuable feedback! @Utopian-io loves and incentivises informative comments.
Contributing on Utopian
Learn how to contribute on our website.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Hey @adam-saudagar
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Congratulations @adam-saudagar! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - Sweden vs England
Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes