Bump d.py version to 2.4.0 (#6401)

Co-authored-by: Ryan <yamikaitou@gmail.com>
This commit is contained in:
Jakub Kuczys
2024-07-10 20:36:47 +02:00
committed by GitHub
parent dd61b669b0
commit 2b1e603124
9 changed files with 173 additions and 36 deletions

View File

@@ -2848,21 +2848,12 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
ctx.bot.description = description
await ctx.tick()
@_set_bot.group(name="avatar", invoke_without_command=True)
@commands.is_owner()
async def _set_bot_avatar(self, ctx: commands.Context, url: str = None):
"""Sets [botname]'s avatar
Supports either an attachment or an image URL.
**Examples:**
- `[p]set bot avatar` - With an image attachment, this will set the avatar.
- `[p]set bot avatar` - Without an attachment, this will show the command help.
- `[p]set bot avatar https://links.flaree.xyz/k95` - Sets the avatar to the provided url.
**Arguments:**
- `[url]` - An image url to be used as an avatar. Leave blank when uploading an attachment.
"""
async def _set_bot_image(
self,
image_type: Literal["avatar", "banner"],
ctx: commands.Context,
url: Optional[str] = None,
):
if len(ctx.message.attachments) > 0: # Attachments take priority
data = await ctx.message.attachments[0].read()
elif url is not None:
@@ -2883,20 +2874,49 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
try:
async with ctx.typing():
await ctx.bot.user.edit(avatar=data)
if image_type == "avatar":
await ctx.bot.user.edit(avatar=data)
else:
await ctx.bot.user.edit(banner=data)
except discord.HTTPException:
await ctx.send(
_(
"Failed. Remember that you can edit my avatar "
"up to two times a hour. The URL or attachment "
"must be a valid image in either JPG, PNG, or GIF format."
if image_type == "avatar":
await ctx.send(
_(
"Failed. Remember that you can edit my avatar "
"up to two times a hour. The URL or attachment "
"must be a valid image in either JPG, PNG, GIF, or WEBP format."
)
)
else:
await ctx.send(
_(
"Failed. Remember that you can edit my banner "
"up to two times a hour. The URL or attachment "
"must be a valid image in either JPG, PNG, GIF, or WEBP format."
)
)
)
except ValueError:
await ctx.send(_("JPG / PNG / GIF format only."))
await ctx.send(_("JPG / PNG / GIF / WEBP format only."))
else:
await ctx.send(_("Done."))
@_set_bot.group(name="avatar", invoke_without_command=True)
@commands.is_owner()
async def _set_bot_avatar(self, ctx: commands.Context, url: str = None):
"""Sets [botname]'s avatar
Supports either an attachment or an image URL.
**Examples:**
- `[p]set bot avatar` - With an image attachment, this will set the avatar.
- `[p]set bot avatar` - Without an attachment, this will show the command help.
- `[p]set bot avatar https://avatars.githubusercontent.com/u/23690422` - Sets the avatar to the provided url.
**Arguments:**
- `[url]` - An image url to be used as an avatar. Leave blank when uploading an attachment.
"""
await self._set_bot_image("avatar", ctx, url)
@_set_bot_avatar.command(name="remove", aliases=["clear"])
@commands.is_owner()
async def _set_bot_avatar_remove(self, ctx: commands.Context):
@@ -2910,6 +2930,36 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
await ctx.bot.user.edit(avatar=None)
await ctx.send(_("Avatar removed."))
@_set_bot.group(name="banner", invoke_without_command=True)
@commands.is_owner()
async def _set_bot_banner(self, ctx: commands.Context, url: str = None):
"""Sets [botname]'s banner
Supports either an attachment or an image URL.
**Examples:**
- `[p]set bot banner` - With an image attachment, this will set the banner.
- `[p]set bot banner` - Without an attachment, this will show the command help.
- `[p]set bot banner https://opengraph.githubassets.com` - Sets the banner to the provided url.
**Arguments:**
- `[url]` - An image url to be used as an banner. Leave blank when uploading an attachment.
"""
await self._set_bot_image("banner", ctx, url)
@_set_bot_banner.command(name="remove", aliases=["clear"])
@commands.is_owner()
async def _set_bot_banner_remove(self, ctx: commands.Context):
"""
Removes [botname]'s banner.
**Example:**
- `[p]set bot banner remove`
"""
async with ctx.typing():
await ctx.bot.user.edit(banner=None)
await ctx.send(_("Banner removed."))
@_set_bot.command(name="username", aliases=["name"])
@commands.is_owner()
async def _set_bot_username(self, ctx: commands.Context, *, username: str):