Skip to content

Commit c7e60d4

Browse files
CringleySDayspre-commit-ci[bot]Lulalaby
authored
chore: Typehinting arguments and variable for examples (#1855)
* typehinting arguments and variable * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lala Sabathil <[email protected]>
1 parent a9e9ae0 commit c7e60d4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

examples/views/channel_select.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ class DropdownView(discord.ui.View):
99
@discord.ui.channel_select(
1010
placeholder="Select channels...", min_values=1, max_values=3
1111
) # Users can select a maximum of 3 channels in the dropdown
12-
async def channel_select_dropdown(self, select, interaction):
12+
async def channel_select_dropdown(
13+
self, select: discord.ui.Select, interaction: discord.Interaction
14+
) -> None:
1315
await interaction.response.send_message(
1416
f"You selected the following channels:"
1517
+ f", ".join(f"{channel.mention}" for channel in select.values)
1618
)
1719

1820

19-
bot = discord.Bot(debug_guilds=[...])
21+
bot: discord.Bot = discord.Bot(debug_guilds=[...])
2022

2123

2224
@bot.slash_command()
23-
async def channel_select(ctx: discord.ApplicationContext):
25+
async def channel_select(ctx: discord.ApplicationContext) -> None:
2426
"""Sends a message with our dropdown that contains a channel select."""
2527

2628
# Create the view containing our dropdown
@@ -31,7 +33,7 @@ async def channel_select(ctx: discord.ApplicationContext):
3133

3234

3335
@bot.event
34-
async def on_ready():
36+
async def on_ready() -> None:
3537
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
3638
print("------")
3739

examples/views/role_select.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ class DropdownView(discord.ui.View):
99
@discord.ui.role_select(
1010
placeholder="Select roles...", min_values=1, max_values=3
1111
) # Users can select a maximum of 3 roles in the dropdown
12-
async def role_select_dropdown(self, select, interaction):
12+
async def role_select_dropdown(
13+
self, select: discord.ui.Select, interaction: discord.Interaction
14+
) -> None:
1315
await interaction.response.send_message(
1416
f"You selected the following roles:"
1517
+ f", ".join(f"{role.mention}" for role in select.values)
1618
)
1719

1820

19-
bot = discord.Bot(debug_guilds=[...])
21+
bot: discord.Bot = discord.Bot(debug_guilds=[...])
2022

2123

2224
@bot.slash_command()
23-
async def role_select(ctx: discord.ApplicationContext):
25+
async def role_select(ctx: discord.ApplicationContext) -> None:
2426
"""Sends a message with our dropdown that contains a role select."""
2527

2628
# Create the view containing our dropdown
@@ -31,7 +33,7 @@ async def role_select(ctx: discord.ApplicationContext):
3133

3234

3335
@bot.event
34-
async def on_ready():
36+
async def on_ready() -> None:
3537
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
3638
print("------")
3739

0 commit comments

Comments
 (0)