Skip to content

Commit

Permalink
prod (#468)
Browse files Browse the repository at this point in the history
* added type hinting in code examples (#451)


Signed-off-by: Lala Sabathil <[email protected]>
Co-authored-by: Lala Sabathil <[email protected]>
Co-authored-by: Dorukyum <[email protected]>

* fix: remove community resources which are not open-source

Signed-off-by: Lala Sabathil <[email protected]>

* Delete .github/dependabot.yml (#464)

Signed-off-by: Lala Sabathil <[email protected]>

* chore(deps): Bump peaceiris/actions-gh-pages from 3 to 4 (#457)

Bumps [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) from 3 to 4.
- [Release notes](https://github.com/peaceiris/actions-gh-pages/releases)
- [Changelog](https://github.com/peaceiris/actions-gh-pages/blob/main/CHANGELOG.md)
- [Commits](peaceiris/actions-gh-pages@v3...v4)

---
updated-dependencies:
- dependency-name: peaceiris/actions-gh-pages
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump github/codeql-action from 2 to 3 (#456)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): Bump actions/setup-python from 4 to 5 (#455)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(metadata): change embed icon to match main website (#465)

* feat(metadata): change Discord embed icon `image` to `thumbnail`

* fix: image sizing

* fix: metadata type

* docs: remove `#ext-pages` channel (#466)

Signed-off-by: JustaSqu1d <[email protected]>

* docs: add more information about application commands (#467)

* docs: add option decorator

* docs: slash command groups in cogs

* docs: minor grammar fix

* fix: spelling mistake

---------

Signed-off-by: Lala Sabathil <[email protected]>
Signed-off-by: Lala Sabathil <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: JustaSqu1d <[email protected]>
Co-authored-by: Yellow-Beans <[email protected]>
Co-authored-by: Dorukyum <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JustaSqu1d <[email protected]>
  • Loading branch information
5 people authored Jun 5, 2024
1 parent 842fb7a commit 7296141
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 36 deletions.
15 changes: 0 additions & 15 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ jobs:

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- run: pip install codespell
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/devskim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
uses: microsoft/DevSkim-Action@v1

- name: Upload DevSkim scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: devskim-results.sarif
2 changes: 1 addition & 1 deletion .github/workflows/njsscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
with:
args: '. --sarif --output results.sarif || true'
- name: Upload njsscan report
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion docs/extensions/pages/paginator-basics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ For a comprehensive list of examples showing all `Paginator` functionality, plea

## Support and Feedback
If you have any questions, suggestions, or feedback for `ext.pages`, please join the
[discord server](https://discord.gg/pycord) and check out the #ext-pages channel.
[Discord server](https://discord.gg/pycord).
2 changes: 1 addition & 1 deletion docs/extensions/tasks/tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ doing very useful stuff.
doing very useful stuff.
```

For a more useful example here's a task in a cog context ripped straight from the [docs](https://docs.pycord.dev/en/stable/ext/tasks/index.html#recepies):
For a more useful example here's a task in a cog context ripped straight from the [docs](https://docs.pycord.dev/en/stable/ext/tasks/index.html#recipes):

```py
from discord.ext import tasks, commands
Expand Down
45 changes: 37 additions & 8 deletions docs/interactions/application-commands/slash-commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ Here's what the registered subcommands will look like in the Slash Command Menu:

You'll notice that there's the name of the Slash Command Group and then the name of the subcommand separated by a space.

:::

:::info Cogs

If you are looking to add Slash Command Groups to cogs, please look at our [Cogs page](../../popular-topics/cogs)!

:::

## Sub-groups

We've made a subcommand group, but did you know that you could create a group inside another?
Expand All @@ -143,12 +151,14 @@ The command created above can be invoked by typing `/math advanced square_root`.

Whenever you're using Slash Commands, you might notice that you can specify parameters that the user has to set or can optionally set. These are called Options.

Since you want different inputs from Options, you'll have to specify the type for that Option. There are a few ways of doing this.
Options can also include a description to provide more information. [You can learn more about Options in our documentation!](https://docs.pycord.dev/en/stable/api/application_commands.html#discord.Option)

Since you want different inputs from Options, you'll have to specify the type for that Option; there are a few ways of doing this.

<Tabs>
<TabItem value="0" label="Using Type Annotations" default>

You could use Type Annotations and let Pycord figure out the option type, like shown below.
You could use Type Annotations and let Pycord figure out the option type or explicitly specified using the [`SlashCommandOptionType`](https://docs.pycord.dev/en/stable/api/enums.html#discord.SlashCommandOptionType) enum.

```python
import discord
Expand All @@ -162,6 +172,16 @@ async def add(ctx, first: discord.Option(int), second: discord.Option(int)):
sum = first + second
await ctx.respond(f"The sum of {first} and {second} is {sum}.")

@bot.command()
# this explicitly tells pycord what types the options are instead
async def join(
ctx,
first: discord.Option(discord.SlashCommandOptionType.string),
second: discord.Option(discord.SlashCommandOptionType.string)
):
joined = first + second
await ctx.respond(f"When you join \"{first}\" and \"{second}\", you get: \"{joined}\".")

bot.run("TOKEN")
```

Expand All @@ -174,24 +194,33 @@ bot.run("TOKEN")
</div>
The sum of 1 and 1 is 2.
</DiscordMessage>
<DiscordMessage profile="robocord">
<div slot="interactions">
<DiscordInteraction profile="bob" command>
join
</DiscordInteraction>
</div>
When you join "Py" and "cord", you get: "Pycord".
</DiscordMessage>
</DiscordComponent>

</TabItem>
<TabItem value="1" label="Using the SlashCommandOptionType enum">
<TabItem value="1" label="Using option decorator">

You could also explicitly declare the type using the [`SlashCommandOptionType`](https://docs.pycord.dev/en/stable/api/enums.html#discord.SlashCommandOptionType) enum.
Instead of Type Annotations, you can also use the option decorator. This is usually done to have type-hinting.

```python title="Slash Command Type"
import discord

bot = discord.Bot()

@bot.command()
# this explicitly tells pycord what types the options are instead of it figuring it out by itself
@discord.option("first", type=discord.SlashCommandOptionType.string) # type = str also works
@discord.option("second", type=discord.SlashCommandOptionType.string) # type = str also works
async def join(
ctx,
first: discord.Option(discord.SlashCommandOptionType.string),
second: discord.Option(discord.SlashCommandOptionType.string)
first: str,
second: str,
):
joined = first + second
await ctx.respond(f"When you join \"{first}\" and \"{second}\", you get: \"{joined}\".")
Expand All @@ -206,7 +235,7 @@ bot.run("TOKEN")
join
</DiscordInteraction>
</div>
When you join "Hello" and "World!", you get: "Hello World!"
When you join "Py" and "cord", you get: "Pycord".
</DiscordMessage>
</DiscordComponent>

Expand Down
23 changes: 20 additions & 3 deletions docs/popular-topics/cogs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ to avoid making your bot's files messy and cluttered.

## Getting Started

First, you'll need to create a folder to store your cogs, eg. `cogs/`.
First, you'll need to create a folder to store your cogs, e.g. `cogs/`.

Then, create a file inside the folder, eg. `cogs/greetings.py`. By convention, the file name should
Then, create a file inside the folder, e.g. `cogs/greetings.py`. By convention, the file name should
be the same as the name of the cog or module.

We can then create the cog.
Expand All @@ -37,6 +37,23 @@ class Greetings(commands.Cog): # create a class for our cog that inherits from c
async def greet(self, ctx, member: discord.Member):
await ctx.respond(f'{ctx.author.mention} says hello to {member.mention}!')

math = discord.SlashCommandGroup("math", "Spooky math stuff") # create a Slash Command Group called "math"
advanced_math = math.create_subgroup(
"advanced",
"super hard math commands!"
)

@math.command()
async def add(self, a: int, b: int):
c = a + b
await ctx.respond(f"{a} + {b} is {c}.")

@advanced_math.command()
async def midpoint(self, x1: float, y1: float, x2: float, y2: float):
mid_x = (x1 + x2)/2
mid_y = (y1 + y2)/2
await ctx.respond(f"The midpoint between those coordinates is ({mid_x}, {mid_y}).")

@commands.Cog.listener() # we can add event listeners to our cog
async def on_member_join(self, member): # this is called when a member joins the server
# you must enable the proper intents
Expand All @@ -56,7 +73,7 @@ bot.load_extension('cogs.greetings')
```

This loads the file `cogs/greetings.py` and adds it to the bot.
The argument of `load_extension` should be your cog's path (eg. cogs/greetings.py) without the file
The argument of `load_extension` should be your cog's path (e.g. cogs/greetings.py) without the file
extension and with the `/` replaced with `.`

If you have multiple cogs, you can add them all at once by adding the following code:
Expand Down
15 changes: 15 additions & 0 deletions src/layouts/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ const DefaultLayout: React.FC<DefaultLayoutProps> = ({ title, description, child
<Head>
<title>{ title } - { site.tagline }</title>
<meta name="description" content={ description } />

<meta property="og:type" content="website" />
<meta property="og:description" content="The official guide for making bots and other Discord applications using the Pycord library." />
<meta property="og:title" content="The Pycord Guide" />
<meta property="og:image" content="https://guide.pycord.dev/img/logo.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:alt" content="Pycord Logo" />
<meta property="og:site_name" content={ title } />
<meta property="og:locale" content="en_US" />
<meta property="article:author" content="Pycord Development" />

<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@PycordDev" />
<meta name="twitter:creator" content="@PycordDev" />
<meta name="twitter:title" content={ title } />
<meta name="twitter:description" content="The official guide for making bots and other Discord applications using the Pycord library." />
<meta name="twitter:image" content={"https://guide.pycord.dev/img/logo.png" } />
<meta name="twitter:image:alt" content="Pycord Logo" />
<meta name="theme-color" content="#5865F2" />
</Head>
<Layout>
Expand Down

0 comments on commit 7296141

Please sign in to comment.