Last active
February 11, 2025 16:33
-
-
Save scragly/095b5278a354d46e86f02d643fc3d64b to your computer and use it in GitHub Desktop.
Revisions
-
scragly revised this gist
Feb 17, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ Using it as your first project while trying to learn is a double-edged sword due However in return, you get the opportunity to expose yourself to many more aspects of Python than you normally would! #### ***With the right attitude and determination, learning while building a bot can be an amazingly rewarding experience as you reach your project goals.*** Bots have a huge scope of things you can do with it, so over time you are able to continue to learn and apply more advanced concepts as you grow as a programmer. -
scragly revised this gist
Feb 17, 2020 . 1 changed file with 16 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,13 +33,25 @@ You can check your version with `pip show discord.py`. ## Required Knowledge Interest in creating a Discord bot is a common introduction to Python for those on Discord. Using it as your first project while trying to learn is a double-edged sword due to the large number of concepts a bot can have involved. Learning while making one can be more arduous than picking more beginner friendly alternatives. However in return, you get the opportunity to expose yourself to many more aspects of Python than you normally would! #### With the right attitude and determination, learning while building a bot can be an amazingly rewarding experience as you reach your project goals. Bots have a huge scope of things you can do with it, so over time you are able to continue to learn and apply more advanced concepts as you grow as a programmer. This guide is not a tutorial, but instead aims to help you identify all the concepts you might need, provide resources to make the path to learning as clear and easy as possible, and collates useful examples provided by the community that may address common ideas and concerns that are seen when working on Discord bots. ### Essentials These subjects you should try get familiar with soon after deciding to build with `discord.py`. Reference the list when needed and use the terms provided to find appropriate resources and tutorials on subjects you're not familiar with or feel a little lacking with. This will prevent confusion and frustration when receiving help from others, when reading documentation and when debugging any issues in your code. - Primitive data types - Operators @@ -74,7 +86,7 @@ Having a good grasp on these will prevent confusion and frustration when learnin ### Recommended This section contains subjects that would be extremely helpful in knowing well as you're likely to encounter them during usage, but a deeper understanding of them aren't essential to using `discord.py`. - String formatting - printf-style (`%`) -
scragly revised this gist
Nov 20, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,6 +27,7 @@ You can check your version with `pip show discord.py`. - [Activity Presence](#activity-presence) - [Image Processing](#image-processing) - [Databases](#databases) - [Systemd Service](#systemd-service) </details> -
scragly revised this gist
Nov 20, 2019 . 1 changed file with 4 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -277,8 +277,7 @@ await messagable.send(file=f, embed=e) - [PostgreSQL Database Integration Example](https://gist.github.com/jegfish/cfc7b22e72426f5ced6f87caa6920fd6) - *Credit to Altarrel* #### Systemd Service **botname.service** ```ini [Unit] Description=My Bot Name @@ -295,12 +294,10 @@ Restart=on-failure WantedBy=network-online.target ``` **Directory** `/usr/local/lib/systemd/system` **Service Commands** Refresh systemd after unit file changes: `systemctl daemon-reload` Set service to start on boot: @@ -310,8 +307,7 @@ Start service now: Stop service: `systemctl botname stop` **Viewing Logs** All logs: `journalctl -u botname` Recent logs and continue printing new logs live: -
scragly revised this gist
Nov 20, 2019 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -278,6 +278,7 @@ await messagable.send(file=f, embed=e) #### Systemd Service **botname.service** ```ini [Unit] Description=My Bot Name @@ -295,9 +296,11 @@ WantedBy=network-online.target ``` **Directory** `/usr/local/lib/systemd/system` **Service Commands** Refresh systemd after unit file changes: `systemctl daemon-reload` Set service to start on boot: @@ -308,6 +311,7 @@ Stop service: `systemctl botname stop` **Viewing Logs** All logs: `journalctl -u botname` Recent logs and continue printing new logs live: -
scragly revised this gist
Nov 20, 2019 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -299,16 +299,16 @@ WantedBy=network-online.target **Service Commands** Refresh systemd after unit file changes: `systemctl daemon-reload` Set service to start on boot: `systemctl enable botname` Start service now: `systemctl botname start` Stop service: `systemctl botname stop` **Viewing Logs** All logs: `journalctl -u botname` Recent logs and continue printing new logs live: `journalctl -fu mybot` -
scragly revised this gist
Nov 20, 2019 . 1 changed file with 37 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -275,3 +275,40 @@ await messagable.send(file=f, embed=e) #### Databases - [PostgreSQL Database Integration Example](https://gist.github.com/jegfish/cfc7b22e72426f5ced6f87caa6920fd6) - *Credit to Altarrel* #### Systemd Service **botname.service** ```ini [Unit] Description=My Bot Name After=network-online.target [Service] Type=simple WorkingDirectory=/your/bots/directory ExecStart=/usr/bin/python3 /your/bots/directory/file.py User=username Restart=on-failure [Install] WantedBy=network-online.target ``` **Directory** `/usr/local/lib/systemd/system` **Service Commands** Refresh systemd after unit file changes: `systemctl daemon-reload` Set service to start on boot: `systemctl enable botname` Start service now: `systemctl botname start` Stop service: `systemctl botname stop` **Viewing Logs** All logs: `journalctl -u botname` Recent logs and continue printing new logs live: `journalctl -fu mybot` -
scragly revised this gist
May 12, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -144,16 +144,16 @@ You can also generate it with the [Permissions Calculator](https://discordapi.co ## Using the Basic Client (`discord.Client`) Below is the essential resources to read over to get familiar with the basics functionality of `discord.py`. - [Basic event usage](https://discordpy.readthedocs.io/en/latest/intro.html#basic-concepts) - [Simple bot walkthrough](https://discordpy.readthedocs.io/en/latest/quickstart.html#a-minimal-bot) - [Available events reference](https://discordpy.readthedocs.io/en/latest/api.html#event-reference) - [General API reference](https://discordpy.readthedocs.io/en/latest/api.html#) ## Using the Commands Extension (`commands.Bot`) The Commands Extension has a explanatory documentation walking you through not only what it is and it's basic usage, but also more advanced concepts. Be sure to read the prose documentation in full at: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html It fully covers: - How to create bot using the Commands Extension -
scragly revised this gist
May 3, 2019 . No changes.There are no files selected for viewing
-
scragly revised this gist
Apr 16, 2019 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -194,11 +194,11 @@ The `discord.py` developer community over time have shared examples and referenc The following are a collated list of the most referenced community examples. #### Extensions / Cogs - [Extension/Cog Example](https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be) - *Credit to EvieePy* - [Available Cog Methods](https://gist.github.com/Ikusaba-san/69115b79d33e05ed07ec4a4f14db83b1) - *Credit to MIkusaba* #### Error Handling - [Decent Error Handling Example](https://gist.github.com/EvieePy/7822af90858ef65012ea500bcecf1612) - *Credit to EvieePy* #### Embeds - [Embed Live Designer and Visualiser](https://leovoel.github.io/embed-visualizer/) - *Credit to leovoel* @@ -268,6 +268,10 @@ await messagable.send(file=f, embed=e) - [PIL Image Processing Example Cog](https://gist.github.com/Gorialis/e89482310d74a90a946b44cf34009e88) - *Credit to Gorialis* #### Voice - [Playlist Example](https://gist.github.com/EvieePy/ab667b74e9758433b3eb806c53a19f34) - *Credit to EvieePy* #### Databases - [PostgreSQL Database Integration Example](https://gist.github.com/jegfish/cfc7b22e72426f5ced6f87caa6920fd6) - *Credit to Altarrel* -
scragly revised this gist
Apr 16, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -180,8 +180,8 @@ The official examples can be found on the [source repository](https://github.com The most commonly referenced examples would be: - [Basic Commands Extension Bot](https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py) - [Basic Voice Bot](https://github.com/Rapptz/discord.py/blob/master/examples/basic_voice.py) - [Background Task Example](https://github.com/Rapptz/discord.py/blob/master/examples/background_task.py) #### Permissions Documentation -
scragly revised this gist
Apr 15, 2019 . 1 changed file with 12 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -85,10 +85,10 @@ This section contains subjects that would be extremely helpful in knowing well a ## Essential References Official Documentation: https://discordpy.readthedocs.io/ Source Repository: https://github.com/Rapptz/discord.py ## Creating a Discord Bot Account @@ -146,9 +146,9 @@ You can also generate it with the [Permissions Calculator](https://discordapi.co Below is the essential resources to read over to get familiar with the basics functionality of `discord.py. - [Basic event usage](https://discordpy.readthedocs.io/en/rewrite/intro.html#basic-concepts) - [Simple bot walkthrough](https://discordpy.readthedocs.io/en/latest/quickstart.html#a-minimal-bot) - [Available events reference](https://discordpy.readthedocs.io/en/latest/api.html#event-reference) - [General API reference](https://discordpy.readthedocs.io/en/latest/api.html#) ## Using the Commands Extension (`commands.Bot`) @@ -164,24 +164,24 @@ It fully covers: - Command checks You will also need to reference the following resources: - [Commands Extension exclusive events](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#event-reference) - [Commands Extension API reference](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html) ## FAQ The documentation covers some basic FAQ's, and they are recommended to be read beforehand, and referenced before asking for help in case it covers your issue: https://discordpy.readthedocs.io/en/latest/faq.html ## Examples ### Official Examples and Resources The official examples can be found on the [source repository](https://github.com/Rapptz/discord.py/tree/master/examples). The most commonly referenced examples would be: - [Basic Commands Extension Bot](https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py) - [Basic Voice Bot](https://github.com/Rapptz/discord.py/blob/rewrite/master/basic_voice.py) - [Background Task Example](https://github.com/Rapptz/discord.py/blob/rewrite/master/background_task.py) #### Permissions Documentation -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,10 +34,12 @@ You can check your version with `pip show discord.py`. Using this library involves a fair understanding of the basics, and some additional intermediate knowledge on Python subjects you may not have needed previously. ### Essentials These subjects you should focus on knowing as soon as possible once you've decided to use `discord.py`. Having a good grasp on these will prevent confusion and frustration when learning, reading and understanding documentation, and to understand any examples or help offered to you. - Primitive data types - Operators - Data structures -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,8 +36,6 @@ Using this library involves a fair understanding of the basics, and some additio Below is outlined essential subjects to focus on making sure you have a good grasp on to prevent confusion and frustration during your learning of `discord.py`. It will help you understand the documentation, examples and any help offered to you. ### Essentials - Primitive data types @@ -73,6 +71,8 @@ There's additionally a Recommended section containing subjects that would be ext ### Recommended This section contains subjects that would be extremely helpful in knowing well as you're likely to encounter them during usage, but a deeper understanding of them aren't essential in order to immediately start working with `discord.py`. - String formatting - printf-style (`%`) - Formatted string literals, known as `f-strings` -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 13 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,13 @@ You can check your version with `pip show discord.py`. ## Required Knowledge Using this library involves a fair understanding of the basics, and some additional intermediate knowledge on Python subjects you may not have needed previously. Below is outlined essential subjects to focus on making sure you have a good grasp on to prevent confusion and frustration during your learning of `discord.py`. It will help you understand the documentation, examples and any help offered to you. There's additionally a Recommended section containing subjects that would be extremely helpful in knowing well, but aren't essential in order to immediately start working with `discord.py`. ### Essentials - Primitive data types - Operators @@ -62,10 +68,14 @@ Below is an outline on the required Python knowledge you should have to prevent - `async def` - `async with` - What is blocking? - String formatting - [`str.format()`](https://pyformat.info) ### Recommended - String formatting - printf-style (`%`) - Formatted string literals, known as `f-strings` - Implicit/explicit string concatenation - Logging - Decorators -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ This guide assumes your version of `discord.py` is updated to at least v1.0 or greater. You can check your version with `pip show discord.py`. <details><summary>Show Contents</summary> - [Required Knowledge](#required-knowledge) - [Essential References](#essential-references) -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,8 @@ This guide assumes your version of `discord.py` is updated to at least v1.0 or greater. You can check your version with `pip show discord.py`. <details><summary>Contents</summary> - [Required Knowledge](#required-knowledge) - [Essential References](#essential-references) - [Creating a Discord Bot Account](#creating-a-discord-bot-account) @@ -26,6 +27,7 @@ You can check your version with `pip show discord.py`. - [Activity Presence](#activity-presence) - [Image Processing](#image-processing) - [Databases](#databases) </details> ## Required Knowledge -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,7 @@ This guide assumes your version of `discord.py` is updated to at least v1.0 or greater. You can check your version with `pip show discord.py`. <details><summary>Contents</summary> - [Required Knowledge](#required-knowledge) - [Essential References](#essential-references) - [Creating a Discord Bot Account](#creating-a-discord-bot-account) @@ -25,6 +26,7 @@ You can check your version with `pip show discord.py`. - [Activity Presence](#activity-presence) - [Image Processing](#image-processing) - [Databases](#databases) </details> ## Required Knowledge -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Learning `discord.py` <!-- omit in toc --> This guide assumes your version of `discord.py` is updated to at least v1.0 or greater. You can check your version with `pip show discord.py`. - [Required Knowledge](#required-knowledge) -
scragly revised this gist
Apr 8, 2019 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ # Learning `discord.py` <!-- omit in toc --> This guide assumes your version of `discord.py` is updated to at least v1.0 or greater. You can check your version with `pip show discord.py`. - [Required Knowledge](#required-knowledge) - [Essential References](#essential-references) -
scragly revised this gist
Mar 21, 2019 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -185,7 +185,14 @@ The following are a collated list of the most referenced community examples. - [Embed Live Designer and Visualiser](https://leovoel.github.io/embed-visualizer/) - *Credit to leovoel* - [Embed Element Reference <img src="https://cdn.discordapp.com/attachments/84319995256905728/252292324967710721/embed.png" width="200">](https://cdn.discordapp.com/attachments/84319995256905728/252292324967710721/embed.png) ##### Using Local Images in Embeds ```py f = discord.File("some_file_path", filename="image.png") e = discord.Embed() e.set_image(url="attachment://image.png") await messagable.send(file=f, embed=e) ``` ##### Embed Limits <table> -
scragly revised this gist
Jan 21, 2019 . No changes.There are no files selected for viewing
-
scragly revised this gist
Jan 21, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -244,4 +244,4 @@ The following are a collated list of the most referenced community examples. #### Databases - [PostgreSQL Database Integration Example](https://gist.github.com/jegfish/cfc7b22e72426f5ced6f87caa6920fd6) - *Credit to Altarrel* -
scragly revised this gist
Jan 12, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -225,7 +225,7 @@ The following are a collated list of the most referenced community examples. <td><b>Count</b></td> </tr> <tr> <td>Fields</td> <td>25</td> </tr> </table> -
scragly revised this gist
Oct 28, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,6 +61,7 @@ Below is an outline on the required Python knowledge you should have to prevent - Formatted string literals (f-strings) - Implicit/explicit string concatenation - Logging - Decorators ## Essential References -
scragly revised this gist
Oct 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ ## Required Knowledge Below is an outline on the required Python knowledge you should have to prevent confusion and frustration during your learning of `discord.py`. It will help you understand the documentation, examples and any help offered to you. It will also ensure you're more likely to troubleshoot and debug your code correctly. - Primitive data types - Operators -
scragly created this gist
Oct 28, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,246 @@ # Learning `discord.py` v1.0.0a (rewrite branch) <!-- omit in toc --> - [Required Knowledge](#required-knowledge) - [Essential References](#essential-references) - [Creating a Discord Bot Account](#creating-a-discord-bot-account) - [Client ID](#client-id) - [Bot Token](#bot-token) - [Permissions Integer](#permissions-integer) - [Bot Invite URL](#bot-invite-url) - [Using the Basic Client (`discord.Client`)](#using-the-basic-client-discordclient) - [Using the Commands Extension (`commands.Bot`)](#using-the-commands-extension-commandsbot) - [FAQ](#faq) - [Examples](#examples) - [Official Examples and Resources](#official-examples-and-resources) - [Permissions Documentation](#permissions-documentation) - [Community Examples and Resources](#community-examples-and-resources) - [Extensions / Cogs](#extensions--cogs) - [Error Handling](#error-handling) - [Embeds](#embeds) - [Embed Limits](#embed-limits) - [Emoji](#emoji) - [Activity Presence](#activity-presence) - [Image Processing](#image-processing) - [Databases](#databases) ## Required Knowledge Below is an outline on the required Python knowledge you should have to prevent confusion and frustration during your learning of `discord.py`. Most of this can be established within only a few days of solid work, and will ensure you understand the documentation, examples and any help offered to you. It will also ensure you're more likely to troubleshoot and debug your code correctly. - Primitive data types - Operators - Data structures - Importing - Variables, namespace and scope - Control flow - `while` - `if` - `elif` - `else` - `for` - Exception handling - `try` - `except` - `finally` - `with` - Function definitions - Argument definitions - Argument ordering - Default arguments - Variable length arguments - Classes, objects, attributes and methods - Console usage, interpreters and environments - Asyncio basics - `await` - `async def` - `async with` - What is blocking? - String formatting - printf-style (`%`) - `str.format()` - Formatted string literals (f-strings) - Implicit/explicit string concatenation - Logging ## Essential References Official Documentation: https://discordpy.readthedocs.io/en/rewrite/ Source Repository: https://github.com/Rapptz/discord.py/tree/rewrite ## Creating a Discord Bot Account 1. Navigate to https://discordapp.com/developers/applications and log in if not already. 2. Click on `Create an application` 3. Enter the Application's name. 4. Click on `Bot` on the left side settings menu. 5. Click `Add Bot` and confirm with `Yes, do it!` ### Client ID Your Client ID is the same as the User ID of your Bot. You will need this when creating an invite URL. You can find your Client ID located on the `General Information` settings page of your Application, under the `Name` field. Your Client ID is not a secret, and does not need to be kept private. ### Bot Token Your Bot Token is the token that authorises your Bot account with the API. Think of it like your Bot's API access key. With your token, you can interact with any part of the API that's available to bots. You can find your Bot Token located on the `Bot` settings page of your Application, under the `Username` field. You can click the `Copy` button to copy it without revealing it manually. **Your Bot Token is a secret, and must be kept private.** If you leak your token anywhere other people has access to see it, no matter the duration, you should reset your Bot Token. To reset your token, go to the `Bot` settings page of your Application, and click the `Regenerate` button. Be sure to update the token you're using for your bot script to this new one, as the old one will not work anymore. ### Permissions Integer Discord Permissions are typically represented by a Permissions Integer which represents all the Permissions that have been allowed. You can find a reference to all the available Discord Permissions, their bitwise values and their descriptions here: https://discordapp.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags If you want to create your own Permissions Integer, you can generate it in the `Bot` settings page of your Application, located at the bottom of the page. Tick the permissions you want to be allowing, and it'll update the `Permissions Integer` field, which you can use in your Bot Invite URL to set your bot's default permissions when users go to invite it. ### Bot Invite URL Bot's cannot use a server invite link. Instead, they have to be invited by a member with the `Manage Server` permission. The Bot Invite URL is formatted like: `https://discordapp.com/oauth2/authorize?client_id={CLIENT_ID}&scope=bot&permissions={PERMISSIONS_INTEGER}` You can create the Invite URL for your bot by replacing: `{CLIENT_ID}` with your [Client ID](#client-id) `{PERMISSIONS_INTEGER}` with the [Permissions Integer](#permissions-integer) You can also generate it with the [Permissions Calculator](https://discordapi.com/permissions.html) tool. ## Using the Basic Client (`discord.Client`) Below is the essential resources to read over to get familiar with the basics functionality of `discord.py. - [Basic event usage](https://discordpy.readthedocs.io/en/rewrite/intro.html#basic-concepts) - [Simple bot walkthrough](https://discordpy.readthedocs.io/en/rewrite/quickstart.html#a-minimal-bot) - [Available events reference](https://discordpy.readthedocs.io/en/rewrite/api.html#event-reference) - [General API reference](https://discordpy.readthedocs.io/en/rewrite/api.html#) ## Using the Commands Extension (`commands.Bot`) The Commands Extension has a explanatory documentation walking you through not only what it is and it's basic usage, but also more advanced concepts. Be sure to read the prose documentation in full at: https://discordpy.readthedocs.io/en/rewrite/ext/commands/commands.html It fully covers: - How to create bot using the Commands Extension - How to define commands and their arguments - What the Context object is - Argument Converters - Error Handling basics - Command checks You will also need to reference the following resources: - [Commands Extension exclusive events](https://discordpy.readthedocs.io/en/rewrite/ext/commands/api.html#event-reference) - [Commands Extension API reference](https://discordpy.readthedocs.io/en/rewrite/ext/commands/api.html) ## FAQ The documentation covers some basic FAQ's, and they are recommended to be read beforehand, and referenced before asking for help in case it covers your issue: https://discordpy.readthedocs.io/en/rewrite/faq.html ## Examples ### Official Examples and Resources The official examples can be found on the [source repository](https://github.com/Rapptz/discord.py/tree/rewrite/examples). The most commonly referenced examples would be: - [Basic Commands Extension Bot](https://github.com/Rapptz/discord.py/blob/rewrite/examples/basic_bot.py) - [Basic Voice Bot](https://github.com/Rapptz/discord.py/blob/rewrite/examples/basic_voice.py) - [Background Task Example](https://github.com/Rapptz/discord.py/blob/rewrite/examples/background_task.py) #### Permissions Documentation - [Role Management 101](https://support.discordapp.com/hc/en-us/articles/214836687-Role-Management-101) - [Full Permissions Documentation](https://discordapp.com/developers/docs/topics/permissions) ### Community Examples and Resources The `discord.py` developer community over time have shared examples and references with each other. The following are a collated list of the most referenced community examples. #### Extensions / Cogs - [Extension/Cog Example](https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be) - *Credit to Eviee* - [Available Cog Methods](https://gist.github.com/Ikusaba-san/69115b79d33e05ed07ec4a4f14db83b1) - *Credit to MIkusaba* #### Error Handling - [Decent Error Handling Example](https://gist.github.com/EvieePy/7822af90858ef65012ea500bcecf1612) - *Credit to Eviee* #### Embeds - [Embed Live Designer and Visualiser](https://leovoel.github.io/embed-visualizer/) - *Credit to leovoel* - [Embed Element Reference <img src="https://cdn.discordapp.com/attachments/84319995256905728/252292324967710721/embed.png" width="200">](https://cdn.discordapp.com/attachments/84319995256905728/252292324967710721/embed.png) - [Using Local Images in Embeds Example](https://gist.github.com/Altarrel/cfc7b22e72426f5ced6f87caa6920fd6) - *Credit to Altarrel* ##### Embed Limits <table> <tr> <td><b>Element</b></td> <td><b>Characters</b></td> </tr> <tr> <td>Title</td> <td>256</td> </tr> <tr> <td>Field Name</td> <td>256</td> </tr> <tr> <td>Field Value</td> <td>1024</td> </tr> <tr> <td>Description</td> <td>2048</td> </tr> <tr> <td>Footer</td> <td>2048</td> </tr> <tr> <td><b>Entire Embed</b></td> <td><b>6000</b></td> </tr> <tr> <td colspan=2></td> </tr> <tr> <td><b>Element</b></td> <td><b>Count</b></td> </tr> <tr> <td>Feilds</td> <td>25</td> </tr> </table> #### Emoji - [Bot's Using Emoji](https://gist.github.com/scragly/b8d20aece2d058c8c601b44a689a47a0) #### Activity Presence - [Setting Bot's Discord Activity](https://gist.github.com/scragly/2579b4d335f87e83fbacb7dfd3d32828) #### Image Processing - [PIL Image Processing Example Cog](https://gist.github.com/Gorialis/e89482310d74a90a946b44cf34009e88) - *Credit to Gorialis* #### Databases - [PostgreSQL Database Integration Example](https://gist.github.com/Altarrel/cfc7b22e72426f5ced6f87caa6920fd6) - *Credit to Altarrel*