2. Making your first command - VikingsDev/Dentaku GitHub Wiki

Making your first command

Contribution guidelines

For a full, comprehensive read on contribution, take a look at our CONTRIBUTING.md.

To add your own command, create a file named your command inside the commands folder. For example, if I wanted to make a command called dog, and I wanted users to run it as !dog, I would create a file called dog.py inside commands.

Inside dog.py, start with this template: (Replace all occurrences of 'dog' with your command name.)

from commands.command import Command
from fbchat import Message
from fbchat import Mention


class dog(Command):

    def run(self):
        response_text = "@" + self.author.first_name + " Hello world! This is a dog command."
        mentions = [Mention(self.author_id, length=len(self.author.first_name) + 1)]

        self.client.send(
            Message(text=response_text, mentions=mentions),
            thread_id=self.thread_id,
            thread_type=self.thread_type
        )

    def define_documentation(self):
        self.documentation = {
            "parameters": "None",
            "function": "Undefined."
        }
    

These links might be helpful:

[fbchat Examples](https://fbchat.readthedocs.io/en/stable/examples.html) <br>
[fbchat Full Documentation](https://fbchat.readthedocs.io/en/stable/api.html)