Using the decorator, let's make a custom command, Hi, and provide a reply text for the Discord bot when it sees it. So you don't need one while instructing the Discord bot. Characters like the dollar sign ($), exclamation (!), ampersand (&), and more are common prefixes that precede bot commands.īut we've blanked the prefix in our case. And the command_prefix in the parenthesis lets you specify a character that precedes it. The bot variable invokes custom commands from the command class. #Read your bot token from the txt file in your project root: # Initialize the bot instance and use a blank prefix: ![]() ![]() Here, you'll program your Discord bot to reply with a custom message when you send a text in a channel.īut first, type the following code at the top of your script to initialize your Discord bot: With the virtual environment active, run the following command in your terminal to install these packages: pip install -U discord. Then activate a Python virtual environment.Īlso, you'll have to install discord.py and a voice support package called discord.py. If Python is up to date, open the terminal to your project root. You can check the Python version installed on your PC by entering the following command in your terminal: python -version ![]() If you've not done so already or have an earlier version, go to to download the latest Python version. To program your Discord bot with Python, you'll use the discord.py module, which only works with Python 3.5.3 or later. You can host yours on cloud services like Heroku if you want once everything is set up. For this tutorial, we'll use Python and host the Discord bot on the local machine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |