Skip to content
Merged

prod #234

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7319a4e
Update modal-dialogs.mdx
estebanmathia Oct 1, 2022
0154419
Merge pull request #220 from estebanmathia/patch-1
Lulalaby Oct 1, 2022
e8a08dc
Revert "Update modal-dialogs.mdx" (#221)
NeloBlivion Oct 1, 2022
7910383
fix: Slash Command Capitalization Consistency
JustaSqu1d Oct 3, 2022
0481b33
feat: mention context menu limits
JustaSqu1d Oct 3, 2022
5e00613
fix: grammar and correct information
JustaSqu1d Oct 3, 2022
7e0beeb
fix: codeblock syntax highlighting
JustaSqu1d Oct 3, 2022
a39f180
fix: more codeblock syntax highlighting
JustaSqu1d Oct 3, 2022
111d735
chore: keep order consistent with sidebar
JustaSqu1d Oct 3, 2022
a8297d2
feat: add Dorukyum plugins and update info
JustaSqu1d Oct 3, 2022
d5adc88
fix: missing newline character at end of file
JustaSqu1d Oct 3, 2022
b1fdcc2
chore(deps-dev): bump typescript from 4.8.3 to 4.8.4 (#223)
dependabot[bot] Oct 4, 2022
fcd18db
Merge branch 'main' into patch-1
BobDotCom Oct 4, 2022
adbd7c7
chore(deps): bump actions/checkout from 2 to 3 (#224)
dependabot[bot] Oct 4, 2022
a038c90
Assume pip is on PATH (#206)
BobDotCom Oct 4, 2022
36c2e1d
fix broken example on subclassing bot class
Makiyu-py Oct 8, 2022
3586d80
Merge pull request #225 from Makiyu-py/patch-1
Lulalaby Oct 8, 2022
11bbd06
Merge branch 'main' into patch-1
BobDotCom Oct 9, 2022
0e2f556
Merge pull request #222 from JustaSqu1d/patch-1
Lulalaby Oct 11, 2022
23d0a5e
Add details to the Markdown section
Elitesparkle Oct 12, 2022
827c8b5
Add imports to Slash Command Group example (#228)
Elitesparkle Oct 16, 2022
a502232
Merge branch 'main' into patch-3
Elitesparkle Oct 16, 2022
5f06bed
Fix custom Tip example
Elitesparkle Oct 16, 2022
7c96f82
Merge pull request #229 from Elitesparkle/patch-3
Lulalaby Oct 16, 2022
1eb388d
Merge pull request #233 from Elitesparkle/contributing
Lulalaby Oct 16, 2022
2ad9033
Remove debug_guilds mentions (#232)
Elitesparkle Oct 16, 2022
74b8c04
Fix markdown for .env section (#227)
Elitesparkle Oct 16, 2022
efdfc32
Merge branch 'production' into main
Lulalaby Oct 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
Expand Down
42 changes: 23 additions & 19 deletions docs/getting-started/creating-your-first-bot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,33 @@ getting leaked is to store it in `.env` files.

You can store your tokens in `.env` files. This is a simple way to store sensitive information.

1. Create a file with the name `.env`. Just `.env`, with the dot/period at the start.
2. Define the token in the file, like so:


```env title=".env"
TOKEN = [PASTE YOUR TOKEN HERE]
```

for example:


1. Create a file with the name `.env` (only the extension, with a dot/period at the start and without a name before it).
2. Define the token in the `.env` file (replace the example value with your token).
```env title=".env"
TOKEN = NzkyNzE1NDU0MTk2MDg4ODQy.X-hvzA.Ovy4MCQywSkoMRRclStW4xAYK7I
```
3. Install [`python-dotenv`](https://pypi.org/project/python-dotenv/)
3. Install [`python-dotenv`](https://pypi.org/project/python-dotenv/).
```bash
python -m pip install python-dotenv
```
4. Load the token from the `.env` file.
```python
import dotenv
dotenv.load_dotenv()
token = str(os.getenv("TOKEN"))
```
5. Pass your token as parameter when running the bot.
```python
client.run(token)
```

:::tip

If you are using Git to track your bot's changes, you should create a file called `.gitignore` and add
`.env` to it. This stops your `.env` file from getting tracked along with the rest of your code, and
will not be pushed to a remote Git repository. It will stay secure on your local machine.
will not be pushed to a remote Git repository. As a consequence, it will stay secure on your local machine.

:::

## Coding the Basics

Expand All @@ -123,7 +128,7 @@ import os # default module
from dotenv import load_dotenv

load_dotenv() # load all the variables from the env file
bot = discord.Bot(debug_guilds=[...])
bot = discord.Bot()

@bot.event
async def on_ready():
Expand Down Expand Up @@ -165,14 +170,13 @@ is a module that we will use to load the env file. You installed this with `pip
Next, we load the env file with `load_dotenv()`.

```py
bot = discord.Bot(debug_guilds=[...])
bot = discord.Bot()
```

In this line, we create a new instance of [`discord.Bot`](https://docs.pycord.dev/en/master/api.html#discord.Bot).
In this object, we pass a `debug_guilds` argument, which is a list of guild IDs that the bot's application
commands will appear in. This is beneficial for testing purposes when we are testing a new command
or two and don't want everyone to be able to use it. If debug guilds are not specified, all of the
servers the bot is in will have access to your slash commands.
In this object, we can pass various parameters for configuration purposes, such as `owner_ids`
and [`intents`](https://docs.pycord.dev/en/stable/api.html?highlight=get_message#discord.Intents).



```py
Expand Down
139 changes: 116 additions & 23 deletions docs/getting-started/more-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ First, you need to ask Discord to send you events. This is done via "Intents". R

Once you understand what intents are, you can enable the events you need, or just use the default ones with `discord.Intents.all()`.

Now that that's done, let's add an event handler for when a user joins the server. We will use the `on_member_join` event. We will send a private message to the user welcoming them to the server.
Now that that's done, let's add an event handler for when a user joins the server. We will use the [`on_member_join` event](https://docs.pycord.dev/en/master/api.html#discord.on_member_join). We will send a private message to the user welcoming them to the server.

```python
@bot.event
Expand Down Expand Up @@ -218,16 +218,21 @@ method, you can set a small footer that holds a message. This has `text` and `ic
- Author - With the [`set_author`](https://docs.pycord.dev/en/master/api.html#discord.Embed.set_author)
method, you can set an author for the embed. This is a small text field at the top of the embed. This
includes `name`, `url` and `icon_url` kwargs.
- Thumbnail - With the [`set_thumbnial`](https://docs.pycord.dev/en/master/api.html#discord.Embed.set_thumbnail)
- Thumbnail - With the [`set_thumbnail`](https://docs.pycord.dev/en/master/api.html#discord.Embed.set_thumbnail)
method, you can set a small image to reside at the top-right of the embed. This has a single `url` kwarg.
- Image - With the [`set_image`](https://docs.pycord.dev/en/master/api.html#discord.Embed.set_image)
method, you can set an image to sit at the bottom of an embed. This has a single `url` kwarg.

There are a lot more methods and attributes you can use to configure embeds. Here, we just covered the basics. Also remember that all of these values are not necessary in an embed. An embed may only contain a few of these, for example, only a description, or a title and a description, and so on.
There are a lot more methods and attributes you can use to configure embeds. Here, we just covered the basics. Also, remember that all of these values are not necessary in an embed. An embed may only contain a few of these. For example, only a description, a title and a description, and so on.

### Markdown
Markdown is a type of markup language that's limited in terms of formatting yet simple. Discord allows
for a watered-down version of markdown to be in their messages. This includes:
for a watered-down version of markdown to be in their messages.

#### Text Markdown

Text formatting can be used in messages and in most embed parts,
as explained in the dedicated section below.

<table>
<tr>
Expand All @@ -250,34 +255,122 @@ for a watered-down version of markdown to be in their messages. This includes:
</tr>
</table>

Sadly, Discord does not support other types, such as hyperlinks. The only supported places for hyperlinks are
in embeds and messages sent through webhooks.
#### Code Markdown

Adding markdown to your embeds or messages will give your bot the sparkle it needs.
To create a single-line code block without syntax highlight, wrap the text between single backticks.
This code block will only add a dark background to the text.

```
\`print("Hello world!")\`
```

Here is an example for a hyperlink in embeds.
To create a multi-line code block without syntax highlight, wrap the text between triple backticks
on first and last line. This type of code block will encase the code inside a box.

```
[Click here!](https://pycord.dev/)
\`\`\`
message = "Hello world!"
print(message)
\`\`\`
```
Inside the embed, the example above will look like this: [`Click here!`](https://pycord.dev/)

:::caution

Some embed fields, such as the footer, do not support markdown *at all*, including bold and italics.

:::
To create a multi-line block with syntax highlight, add the name of the language you are using right after
the triple backticks on the first line. For example, for Python you can write either "python" or "py".

#### Code Markdown
```
\`\`\`python
message = "Hello world!"
print(message)
\`\`\`
```

For code markdown, you can choose between `Code Text` and `Code Blocks`.
If you want to use syntax highlight for a single line of code, you still have to format it
like a multi-line block but the code must be on a separate line than the triple backticks.

- \`Code Text\`
- \`\`\`
#### Quote Markdown

Code Blocks
\`\`\`
To create a single-line quote block, start the line with `>` followed by a space.

Code Blocks support different programming languages, such as Python.
```
> This is a single-line quote.
```

If you start your Code Block with <code>```python</code>, you can send readable Python code to Discord.
To create a multi-line quote block, write `>>>` followed by a space. All text
from that point onwards will be included in that quote block.

```
>>> This is a
multi-line quote.
```

#### Spoiler Markdown

To hide a spoiler, encase the text between double pipes. The users
will have to click on it before being able to see the text contained in it.

```
||spoiler||
```

#### Link Markdown

Link formatting only works in embeds and messages sent through webhooks,
by using the following syntax:

```
[Pycord](https://pycord.dev/)
```

Inside the supported elements that have just been mentioned,
the example above will look like this: [`Pycord`](https://pycord.dev/)

Outside of them, the link will still be clickable but the formatting will be ignored,
therefore the example above will look similarly to this: `[Pycord](https://pycord.dev/)`

#### Embed Markdown

Adding markdown to your embeds or messages will give your bot the sparkle it needs,
however, markdown is limited inside embeds. Use the following table as a reference
and keep in mind that embed title and filed names will always show in **bold**.

<table>
<thead>
<tr>
<th>Part</th>
<th>Text</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<tr>
<td>Embed Author</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>Embed Title</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Embed Description</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Field Name</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Field Value</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Embed Footer</td>
<td>No</td>
<td>No</td>
</tr>
</tbody>
</table>
14 changes: 7 additions & 7 deletions docs/getting-started/rules-and-common-practices.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Providing a Terms of Service for your bot is optional, though usually a best pra
what they can and cannot do with your service, and makes it easier to settle disputes if someone
disagrees with you.

Read more in Discord's official [Legal Docs](https://discord.com/developers/docs/legal)
Read more in Discord's official [Legal Docs](https://discord.com/developers/docs/legal).

### Developer Policy

We could list almost every rule about using Discord's API here. *Or* we could simply link Discord's
developer policy to make it easier on us. You can find Discord's developer policy
Developer Policy to make it easier on us. You can find Discord's Developer Policy
[here](https://discord.com/developers/docs/policy). This outlines what you can and cannot do with
Discord's developer API. And, don't worry, it's completely readable and understandable.
Discord's Developer API. And, don't worry, it's completely readable and understandable.

## Best Practices

Expand Down Expand Up @@ -78,8 +78,8 @@ bot verification, so verifying as soon as possible gives them enough time to ver
reaches the 100 server cap. If a bot is not verified, it cannot grow beyond 100 servers.

It's also a good idea to only apply for the privileged intents that you need. Applying for intents
your bot doesn't use wastes both your time and Discord's time, as your whole verification request
can be denied simply because you applied for an intent you didn't need.
your bot doesn't use wastes both your time and Discord's time, as your privileged intent request
will be denied simply because you applied for an intent you didn't need.

### Subclassing

Expand All @@ -106,7 +106,7 @@ the Creating Your First Bot guide.
You always want to back up your bot's data. This includes both its code *and* its databases. This way,
if something tragic happens, such as your host failing a data migration or you breaking your Raspberry
Pi's SD card that held your bot, you'll still have its precious user data. I have a small program for
my bot that uploads its databases to a remote GitHub repository now and then to not lose any data.
my bot that uploads its databases to a remote GitHub repository every now and then to not lose any data.
It may be smarter to find a bit more of a reliable way to do so, though.

Public or private, having a local Git repository connected to a remote one is a good idea for making
Expand Down Expand Up @@ -169,7 +169,7 @@ works entirely on files. However, if for some reason you cannot read/write to an
lots of data, SQLite might not be for you.

While SQLite is a part of the Python Standard Library as the `sqlite3` package, we recommend not using it as it is
synchronous and blocking. You should use an asynchronous alternative, such as `aiosqlite`.
synchronous and blocking. You should use an asynchronous alternative, such as [`aiosqlite`](https://pypi.org/project/aiosqlite/).

#### PostgreSQL
PostgreSQL is also based on SQL, but it also has more features than SQLite. It's compliant with the SQL standard,
Expand Down
14 changes: 7 additions & 7 deletions docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ You can find instructions for that [here](More/virtual-environments).

To install Pycord, you can use the following command in your terminal:

python3 -m pip install py-cord
pip install py-cord

:::tip
Remember that you need to install `py-cord`, not `pycord`.
Also, the `python3` command varies depending on your installation. It might be `python` or `python3.8` as an example.
Also, the `pip` command varies depending on your installation. For example, it might be `python3 -m pip` on macOS/Linux or `py3 -m pip` on some versions of Windows.
:::

If you need voice support for your bot, you should run:

python3 -m pip install "py-cord[voice]"
pip install "py-cord[voice]"

## Migration

### Updating Pycord

If you are upgrading from a previous version of Pycord, you can use the following command in your terminal to upgrade to the latest version:

python3 -m pip install -U py-cord
pip install -U py-cord

### Migrating from other libraries

If you are migrating from another library, say, `discord.py`, first of all, you need to uninstall it.

python3 -m pip uninstall discord.py
pip uninstall discord.py

Then, you can install Pycord, it's as simple as that!:

python3 -m pip install py-cord
pip install py-cord

:::caution
Uninstalling `discord.py` *after* installing `py-cord` can cause issues. Make sure to uninstall it first!
Expand All @@ -61,7 +61,7 @@ The development build comes with cutting edge features and new functionality, bu

To install the development build, you can use the following command in your terminal:

python -m pip install -U git+https://github.com/Pycord-Development/pycord
pip install -U git+https://github.com/Pycord-Development/pycord

:::important
Git is required to install this build. [Learn how you can install Git](./more/git).
Expand Down
8 changes: 7 additions & 1 deletion docs/interactions/application-commands/context-menus.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ import DiscordComponent, { defaultOptions } from "../../../src/components/Discor
When you right-click a message, you may see an option called "Apps". Hover over it and you can see
commands a bot can run with that message. These are called message commands.

When you right-click a message in the user list, you can once again see an option called "Apps".
When you right-click a user in the user list, you can once again see an option called "Apps".
Hover over it and you can see commands a bot can run with that message. These are called user commands.

Together, these two are called Context Menus or Context Menu Commands. These commands work very much like normal commands, except they take a member or message.

:::note

A bot can have up to 5 global Context Menus of each type.

:::

## User Commands

Creating a user command is very simple.
Expand Down
Loading