Skip to content

Commit 7296141

Browse files
LulalabyYellow-BeansDorukyumdependabot[bot]JustaSqu1d
authored
prod (#468)
* 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]>
1 parent 842fb7a commit 7296141

File tree

12 files changed

+82
-36
lines changed

12 files changed

+82
-36
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/codacy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ jobs:
5555

5656
# Upload the SARIF file generated in the previous step
5757
- name: Upload SARIF results file
58-
uses: github/codeql-action/upload-sarif@v2
58+
uses: github/codeql-action/upload-sarif@v3
5959
with:
6060
sarif_file: results.sarif

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

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

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

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v2
70+
uses: github/codeql-action/analyze@v3

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v4
9-
- uses: actions/setup-python@v4
9+
- uses: actions/setup-python@v5
1010
with:
1111
python-version: "3.x"
1212
- run: pip install codespell

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
# Popular action to deploy to GitHub Pages:
2727
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
2828
- name: Deploy to GitHub Pages
29-
uses: peaceiris/actions-gh-pages@v3
29+
uses: peaceiris/actions-gh-pages@v4
3030
with:
3131
github_token: ${{ secrets.GITHUB_TOKEN }}
3232
# Build output to publish to the `gh-pages` branch:

.github/workflows/devskim.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
uses: microsoft/DevSkim-Action@v1
3030

3131
- name: Upload DevSkim scan results to GitHub Security tab
32-
uses: github/codeql-action/upload-sarif@v2
32+
uses: github/codeql-action/upload-sarif@v3
3333
with:
3434
sarif_file: devskim-results.sarif

.github/workflows/njsscan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ jobs:
3636
with:
3737
args: '. --sarif --output results.sarif || true'
3838
- name: Upload njsscan report
39-
uses: github/codeql-action/upload-sarif@v2
39+
uses: github/codeql-action/upload-sarif@v3
4040
with:
4141
sarif_file: results.sarif

docs/extensions/pages/paginator-basics.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,4 @@ For a comprehensive list of examples showing all `Paginator` functionality, plea
156156

157157
## Support and Feedback
158158
If you have any questions, suggestions, or feedback for `ext.pages`, please join the
159-
[discord server](https://discord.gg/pycord) and check out the #ext-pages channel.
159+
[Discord server](https://discord.gg/pycord).

docs/extensions/tasks/tasks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ doing very useful stuff.
3535
doing very useful stuff.
3636
```
3737

38-
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):
38+
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):
3939

4040
```py
4141
from discord.ext import tasks, commands

docs/interactions/application-commands/slash-commands.mdx

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ Here's what the registered subcommands will look like in the Slash Command Menu:
119119

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

122+
:::
123+
124+
:::info Cogs
125+
126+
If you are looking to add Slash Command Groups to cogs, please look at our [Cogs page](../../popular-topics/cogs)!
127+
128+
:::
129+
122130
## Sub-groups
123131

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

144152
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.
145153

146-
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.
154+
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)
155+
156+
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.
147157

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

151-
You could use Type Annotations and let Pycord figure out the option type, like shown below.
161+
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.
152162

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

175+
@bot.command()
176+
# this explicitly tells pycord what types the options are instead
177+
async def join(
178+
ctx,
179+
first: discord.Option(discord.SlashCommandOptionType.string),
180+
second: discord.Option(discord.SlashCommandOptionType.string)
181+
):
182+
joined = first + second
183+
await ctx.respond(f"When you join \"{first}\" and \"{second}\", you get: \"{joined}\".")
184+
165185
bot.run("TOKEN")
166186
```
167187

@@ -174,24 +194,33 @@ bot.run("TOKEN")
174194
</div>
175195
The sum of 1 and 1 is 2.
176196
</DiscordMessage>
197+
<DiscordMessage profile="robocord">
198+
<div slot="interactions">
199+
<DiscordInteraction profile="bob" command>
200+
join
201+
</DiscordInteraction>
202+
</div>
203+
When you join "Py" and "cord", you get: "Pycord".
204+
</DiscordMessage>
177205
</DiscordComponent>
178206

179207
</TabItem>
180-
<TabItem value="1" label="Using the SlashCommandOptionType enum">
208+
<TabItem value="1" label="Using option decorator">
181209

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

184212
```python title="Slash Command Type"
185213
import discord
186214

187215
bot = discord.Bot()
188216

189217
@bot.command()
190-
# this explicitly tells pycord what types the options are instead of it figuring it out by itself
218+
@discord.option("first", type=discord.SlashCommandOptionType.string) # type = str also works
219+
@discord.option("second", type=discord.SlashCommandOptionType.string) # type = str also works
191220
async def join(
192221
ctx,
193-
first: discord.Option(discord.SlashCommandOptionType.string),
194-
second: discord.Option(discord.SlashCommandOptionType.string)
222+
first: str,
223+
second: str,
195224
):
196225
joined = first + second
197226
await ctx.respond(f"When you join \"{first}\" and \"{second}\", you get: \"{joined}\".")
@@ -206,7 +235,7 @@ bot.run("TOKEN")
206235
join
207236
</DiscordInteraction>
208237
</div>
209-
When you join "Hello" and "World!", you get: "Hello World!"
238+
When you join "Py" and "cord", you get: "Pycord".
210239
</DiscordMessage>
211240
</DiscordComponent>
212241

docs/popular-topics/cogs.mdx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ to avoid making your bot's files messy and cluttered.
88

99
## Getting Started
1010

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

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

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

40+
math = discord.SlashCommandGroup("math", "Spooky math stuff") # create a Slash Command Group called "math"
41+
advanced_math = math.create_subgroup(
42+
"advanced",
43+
"super hard math commands!"
44+
)
45+
46+
@math.command()
47+
async def add(self, a: int, b: int):
48+
c = a + b
49+
await ctx.respond(f"{a} + {b} is {c}.")
50+
51+
@advanced_math.command()
52+
async def midpoint(self, x1: float, y1: float, x2: float, y2: float):
53+
mid_x = (x1 + x2)/2
54+
mid_y = (y1 + y2)/2
55+
await ctx.respond(f"The midpoint between those coordinates is ({mid_x}, {mid_y}).")
56+
4057
@commands.Cog.listener() # we can add event listeners to our cog
4158
async def on_member_join(self, member): # this is called when a member joins the server
4259
# you must enable the proper intents
@@ -56,7 +73,7 @@ bot.load_extension('cogs.greetings')
5673
```
5774

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

6279
If you have multiple cogs, you can add them all at once by adding the following code:

src/layouts/DefaultLayout.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,24 @@ const DefaultLayout: React.FC<DefaultLayoutProps> = ({ title, description, child
1616
<Head>
1717
<title>{ title } - { site.tagline }</title>
1818
<meta name="description" content={ description } />
19+
20+
<meta property="og:type" content="website" />
1921
<meta property="og:description" content="The official guide for making bots and other Discord applications using the Pycord library." />
2022
<meta property="og:title" content="The Pycord Guide" />
2123
<meta property="og:image" content="https://guide.pycord.dev/img/logo.png" />
24+
<meta property="og:image:type" content="image/png" />
25+
<meta property="og:image:alt" content="Pycord Logo" />
26+
<meta property="og:site_name" content={ title } />
27+
<meta property="og:locale" content="en_US" />
28+
<meta property="article:author" content="Pycord Development" />
29+
30+
<meta name="twitter:card" content="summary" />
31+
<meta name="twitter:site" content="@PycordDev" />
32+
<meta name="twitter:creator" content="@PycordDev" />
33+
<meta name="twitter:title" content={ title } />
34+
<meta name="twitter:description" content="The official guide for making bots and other Discord applications using the Pycord library." />
35+
<meta name="twitter:image" content={"https://guide.pycord.dev/img/logo.png" } />
36+
<meta name="twitter:image:alt" content="Pycord Logo" />
2237
<meta name="theme-color" content="#5865F2" />
2338
</Head>
2439
<Layout>

0 commit comments

Comments
 (0)