Skip to content

Commit 9fceff8

Browse files
authored
Merge pull request #537 from Dorukyum/format
Format
2 parents b872cfe + d0927c8 commit 9fceff8

24 files changed

+96
-49
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Please be aware of the following things when filing bug reports.
2626
- Guidance on **how to reproduce the issue**. Ideally, this should have a small code sample that allows us to run and see the issue for ourselves to debug. **Please make sure that the token is not displayed**. If you cannot provide a code snippet, then let us know what the steps were, how often it happens, etc.
2727
- Tell us **what you expected to happen**. That way we can meet that expectation.
2828
- Tell us **what actually happens**. What ends up happening in reality? It's not helpful to say "it fails" or "it doesn't work". Say *how* it failed, do you get an exception? Does it hang? How are the expectations different from reality?
29-
- Tell us **information about your environment**. What version of discord.py are you using? How was it installed? What operating system are you running on? These are valuable questions and information that we use.
29+
- Tell us **information about your environment**. What version of Pycord are you using? How was it installed? What operating system are you running on? These are valuable questions and information that we use.
3030

3131
If the bug report is missing this information then it'll take us longer to fix the issue. We will probably ask for clarification, and barring that if no response was given then the issue will be closed.
3232

discord/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def add_newcog_args(subparser: argparse._SubParsersAction) -> None:
286286
parser.add_argument('--full', help='add all special methods as well', action='store_true')
287287

288288
def parse_args() -> Tuple[argparse.ArgumentParser, argparse.Namespace]:
289-
parser = argparse.ArgumentParser(prog='discord', description='Tools for helping with discord.py')
289+
parser = argparse.ArgumentParser(prog='discord', description='Tools for helping with Pycord')
290290
parser.add_argument('-v', '--version', action='store_true', help='shows the library version')
291291
parser.set_defaults(func=core)
292292

discord/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ async def _run_event(self, coro: Callable[..., Coroutine[Any, Any, Any]], event_
361361
def _schedule_event(self, coro: Callable[..., Coroutine[Any, Any, Any]], event_name: str, *args: Any, **kwargs: Any) -> asyncio.Task:
362362
wrapped = self._run_event(coro, event_name, *args, **kwargs)
363363
# Schedules the task
364-
return asyncio.create_task(wrapped, name=f'discord.py: {event_name}')
364+
return asyncio.create_task(wrapped, name=f'pycord: {event_name}')
365365

366366
def dispatch(self, event: str, *args: Any, **kwargs: Any) -> None:
367367
_log.debug('Dispatching event %s', event)

discord/gateway.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ async def identify(self):
376376
'token': self.token,
377377
'properties': {
378378
'$os': sys.platform,
379-
'$browser': 'discord.py',
380-
'$device': 'discord.py',
379+
'$browser': 'pycord',
380+
'$device': 'pycord',
381381
'$referrer': '',
382382
'$referring_domain': ''
383383
},

examples/app_commands/slash_autocomplete.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import discord
2-
from discord.commands import slash_command, Option
2+
from discord.commands import Option, slash_command
3+
34
bot = discord.Bot()
45

56
COLORS = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
@@ -85,15 +86,19 @@
8586
"yellowgreen",
8687
]
8788

88-
BASIC_ALLOWED = [...] # this would normally be a list of discord user IDs for the purpose of this example
89+
BASIC_ALLOWED = [
90+
...
91+
] # this would normally be a list of discord user IDs for the purpose of this example
8992

9093

9194
async def color_searcher(ctx: discord.AutocompleteContext):
9295
"""Returns a list of matching colors from the LOTS_OF_COLORS list
9396
In this example, we've added logic to only display any results in the returned list if the user's ID exists in the BASIC_ALLOWED list.
9497
This is to demonstrate passing a callback in the discord.utils.basic_autocomplete function.
9598
"""
96-
return [color for color in LOTS_OF_COLORS if ctx.interaction.user.id in BASIC_ALLOWED]
99+
return [
100+
color for color in LOTS_OF_COLORS if ctx.interaction.user.id in BASIC_ALLOWED
101+
]
97102

98103

99104
async def get_colors(ctx: discord.AutocompleteContext):
@@ -115,7 +120,9 @@ async def get_animals(ctx: discord.AutocompleteContext):
115120
elif picked_color == "blue":
116121
return ["blue jay", "blue whale"]
117122
elif picked_color == "indigo":
118-
return ["eastern indigo snake"] # needs to return an iterable even if only one item
123+
return [
124+
"eastern indigo snake"
125+
] # needs to return an iterable even if only one item
119126
elif picked_color == "violet":
120127
return ["purple emperor butterfly", "orchid dottyback"]
121128
else:
@@ -129,14 +136,26 @@ async def autocomplete_example(
129136
animal: Option(str, "Pick an animal!", autocomplete=get_animals),
130137
):
131138
"""This demonstrates using the ctx.options parameter to to create slash command options that are dependent on the values entered for other options."""
132-
await ctx.respond(f"You picked {color} for the color, which allowed you to choose {animal} for the animal.")
139+
await ctx.respond(
140+
f"You picked {color} for the color, which allowed you to choose {animal} for the animal."
141+
)
133142

134143

135144
@bot.slash_command(name="ac_basic_example")
136145
async def autocomplete_basic_example(
137146
ctx: discord.ApplicationContext,
138-
color: Option(str, "Pick a color from this big list", autocomplete=discord.utils.basic_autocomplete(color_searcher)), # Demonstrates passing a callback to discord.utils.basic_autocomplete
139-
animal: Option(str, "Pick an animal from this small list", autocomplete=discord.utils.basic_autocomplete(["snail", "python", "cricket", "orca"])), # Demonstrates passing a static iterable discord.utils.basic_autocomplete
147+
color: Option(
148+
str,
149+
"Pick a color from this big list",
150+
autocomplete=discord.utils.basic_autocomplete(color_searcher),
151+
), # Demonstrates passing a callback to discord.utils.basic_autocomplete
152+
animal: Option(
153+
str,
154+
"Pick an animal from this small list",
155+
autocomplete=discord.utils.basic_autocomplete(
156+
["snail", "python", "cricket", "orca"]
157+
),
158+
), # Demonstrates passing a static iterable discord.utils.basic_autocomplete
140159
):
141160
"""This demonstrates using the discord.utils.basic_autocomplete helper function.
142161
For the `color` option, a callback is passed, where additional logic can be added to determine which values are returned.
@@ -145,4 +164,5 @@ async def autocomplete_basic_example(
145164
Note that the basic_autocomplete function itself will still only return a maximum of 25 items."""
146165
await ctx.respond(f"You picked {color} as your color, and {animal} as your animal!")
147166

167+
148168
bot.run("TOKEN")

examples/app_commands/slash_basic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Note: If you want you can use commands.Bot instead of discord.Bot
77
# Use discord.Bot if you don't want prefixed message commands
88

9-
# With discord.Bot you can use @bot.command as an alias
9+
# With discord.Bot you can use @bot.command as an alias
1010
# of @bot.slash_command but this is overridden by commands.Bot
1111

1212

@@ -28,7 +28,9 @@ async def joined(
2828
ctx, member: discord.Member = None
2929
): # Passing a default value makes the argument optional
3030
user = member or ctx.author
31-
await ctx.respond(f"{user.name} joined at {discord.utils.format_dt(user.joined_at)}")
31+
await ctx.respond(
32+
f"{user.name} joined at {discord.utils.format_dt(user.joined_at)}"
33+
)
3234

3335

3436
# To learn how to add descriptions and choices to options, check slash_options.py

examples/app_commands/slash_cog.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
from discord.commands import slash_command # Importing the decorator that makes slash commands.
12
from discord.ext import commands
2-
from discord.commands import slash_command # Importing the decorator that makes slash commands.
3+
34

45
class Example(commands.Cog):
56
def __init__(self, bot):
67
self.bot = bot
7-
8-
@slash_command(guild_ids=[...]) # Create a slash command for the supplied guilds.
8+
9+
@slash_command(guild_ids=[...]) # Create a slash command for the supplied guilds.
910
async def hello(self, ctx):
1011
await ctx.respond("Hi, this is a slash command from a cog!")
11-
1212

13-
@slash_command() # Not passing in guild_ids creates a global slash command (might take an hour to register).
13+
@slash_command() # Not passing in guild_ids creates a global slash command (might take an hour to register).
1414
async def hi(self, ctx):
15-
await ctx.respond(f"Hi, this is a global slash command from a cog!")
15+
await ctx.respond("Hi, this is a global slash command from a cog!")
16+
1617

1718
def setup(bot):
1819
bot.add_cog(Example(bot))

examples/app_commands/slash_options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ async def hello(
1616
):
1717
await ctx.respond(f"Hello {name}")
1818

19-
bot.run('TOKEN')
19+
20+
bot.run("TOKEN")

examples/app_commands/slash_perms.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import discord
2-
32
# Imports permissions from discord.commands
43
from discord.commands import permissions
54

@@ -8,7 +7,7 @@
87
# Note: If you want you can use commands.Bot instead of discord.Bot
98
# Use discord.Bot if you don't want prefixed message commands
109

11-
# With discord.Bot you can use @bot.command as an alias
10+
# With discord.Bot you can use @bot.command as an alias
1211
# of @bot.slash_command but this is overridden by commands.Bot
1312

1413
# by default, default_permission is set to True, you can use
@@ -31,45 +30,60 @@
3130
# Note: Please replace token, GUILD_ID, USER_ID and ROLE_NAME.
3231

3332
# Guild Slash Command Example with User Permissions
33+
34+
GUILD_ID = ...
35+
USER_ID = ...
36+
37+
3438
@bot.slash_command(guild_ids=[GUILD_ID], default_permission=False)
3539
@permissions.is_user(USER_ID)
3640
async def user(ctx):
3741
"""Say hello to the author""" # the command description can be supplied as the docstring
3842
await ctx.respond(f"Hello {ctx.author}!")
3943

44+
4045
# Guild Slash Command Example with Owner Permissions
4146
@bot.slash_command(guild_ids=[GUILD_ID], default_permission=False)
4247
@permissions.is_owner()
4348
async def owner(ctx):
4449
"""Say hello to the author""" # the command description can be supplied as the docstring
4550
await ctx.respond(f"Hello {ctx.author}!")
4651

52+
4753
# Guild Slash Command Example with Role Permissions
4854
@bot.slash_command(guild_ids=[GUILD_ID], default_permission=False)
4955
@permissions.has_role("ROLE_NAME")
5056
async def role(ctx):
5157
"""Say hello to the author""" # the command description can be supplied as the docstring
5258
await ctx.respond(f"Hello {ctx.author}!")
5359

60+
5461
# Guild Slash Command Example with Any Specified Role Permissions
5562
@bot.slash_command(guild_ids=[GUILD_ID], default_permission=False)
5663
@permissions.has_any_role("ROLE_NAME", "ROLE_NAME2")
5764
async def multirole(ctx):
5865
"""Say hello to the author""" # the command description can be supplied as the docstring
5966
await ctx.respond(f"Hello {ctx.author}!")
6067

68+
6169
# Guild Slash Command Example with Permission Decorator
6270
@bot.slash_command(guild_ids=[GUILD_ID], default_permission=False)
6371
@permissions.permission(user_id=USER_ID, permission=True)
6472
async def permission_decorator(ctx):
6573
"""Say hello to the author""" # the command description can be supplied as the docstring
6674
await ctx.respond(f"Hello {ctx.author}!")
6775

76+
6877
# Guild Slash Command Example with Permissions Kwarg
69-
@bot.slash_command(guild_ids=[GUILD_ID], default_permission=False, permissions=[permissions.Permission(id=USER_ID, type=2, permission=True)])
78+
@bot.slash_command(
79+
guild_ids=[GUILD_ID],
80+
default_permission=False,
81+
permissions=[permissions.Permission(id=USER_ID, type=2, permission=True)],
82+
)
7083
async def permission_kwarg(ctx):
7184
"""Say hello to the author""" # the command description can be supplied as the docstring
7285
await ctx.respond(f"Hello {ctx.author}!")
7386

87+
7488
# To learn how to add descriptions, choices to options check slash_options.py
7589
bot.run("token")

examples/background_task.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from discord.ext import tasks
2-
31
import discord
2+
from discord.ext import tasks
43

54

65
class MyClient(discord.Client):

0 commit comments

Comments
 (0)