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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 173 additions and 36 deletions

View File

@ -2867,7 +2867,7 @@ Supports either an attachment or an image URL.
**Examples:** **Examples:**
- ``[p]set bot avatar`` - With an image attachment, this will set the avatar. - ``[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`` - 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. - ``[p]set bot avatar https://avatars.githubusercontent.com/u/23690422`` - Sets the avatar to the provided url.
**Arguments:** **Arguments:**
- ``[url]`` - An image url to be used as an avatar. Leave blank when uploading an attachment. - ``[url]`` - An image url to be used as an avatar. Leave blank when uploading an attachment.
@ -2895,6 +2895,57 @@ Removes Red's avatar.
**Example:** **Example:**
- ``[p]set bot avatar remove`` - ``[p]set bot avatar remove``
.. _core-command-set-bot-banner:
""""""""""""""
set bot banner
""""""""""""""
.. note:: |owner-lock|
**Syntax**
.. code-block:: none
[p]set bot banner [url]
**Description**
Sets Red'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.
.. _core-command-set-bot-banner-remove:
"""""""""""""""""""""
set bot banner remove
"""""""""""""""""""""
.. note:: |owner-lock|
**Syntax**
.. code-block:: none
[p]set bot banner remove
.. tip:: Alias: ``set bot banner clear``
**Description**
Removes Red's banner.
**Example:**
- ``[p]set bot banner remove``
.. _core-command-set-bot-custominfo: .. _core-command-set-bot-custominfo:
"""""""""""""""""" """"""""""""""""""

View File

@ -397,7 +397,8 @@ async def run_bot(red: Red, cli_flags: Namespace) -> None:
"With that out of the way, depending on who you want to be considered as owner," "With that out of the way, depending on who you want to be considered as owner,"
" you can:\n" " you can:\n"
"a) pass --team-members-are-owners when launching Red" "a) pass --team-members-are-owners when launching Red"
" - in this case Red will treat all members of the bot application's team as owners\n" " - in this case Red will treat members of the bot application's team as owners,"
" if their team role is Owner, Admin, or Developer\n"
f"b) set owner manually with `redbot --edit {cli_flags.instance_name}`\n" f"b) set owner manually with `redbot --edit {cli_flags.instance_name}`\n"
"c) pass owner ID(s) when launching Red with --owner" "c) pass owner ID(s) when launching Red with --owner"
" (and --co-owner if you need more than one) flag\n" " (and --co-owner if you need more than one) flag\n"

View File

@ -40,10 +40,10 @@ HUMANIZED_PERM = {
"add_reactions": _("Add Reactions"), "add_reactions": _("Add Reactions"),
"view_audit_log": _("View Audit Log"), "view_audit_log": _("View Audit Log"),
"priority_speaker": _("Priority Speaker"), "priority_speaker": _("Priority Speaker"),
"stream": _("Go Live"), "stream": _("Video"),
"read_messages": _("Read Text Channels & See Voice Channels"), "read_messages": _("Read Text Channels & See Voice Channels"),
"send_messages": _("Send Messages"), "send_messages": _("Send Messages"),
"send_tts_messages": _("Send TTS Messages"), "send_tts_messages": _("Send Text-to-speech Messages"),
"manage_messages": _("Manage Messages"), "manage_messages": _("Manage Messages"),
"embed_links": _("Embed Links"), "embed_links": _("Embed Links"),
"attach_files": _("Attach Files"), "attach_files": _("Attach Files"),
@ -70,12 +70,16 @@ HUMANIZED_PERM = {
"create_private_threads": _("Create Private Threads"), "create_private_threads": _("Create Private Threads"),
"external_stickers": _("Use External Stickers"), "external_stickers": _("Use External Stickers"),
"send_messages_in_threads": _("Send Messages in Threads"), "send_messages_in_threads": _("Send Messages in Threads"),
"start_embedded_activities": _("Start Activities"), "use_embedded_activities": _("Use Activities"),
"moderate_members": _("Moderate Member"), "moderate_members": _("Time out members"),
"view_creator_monetization_analytics": _("View Creator Monetization Analytics"),
"use_soundboard": _("Use Soundboard"), "use_soundboard": _("Use Soundboard"),
"create_expressions": _("Create Expressions"), "create_expressions": _("Create Expressions"),
"create_events": _("Create Events"),
"use_external_sounds": _("Use External Sounds"), "use_external_sounds": _("Use External Sounds"),
"send_voice_messages": _("Send Voice Messages"), "send_voice_messages": _("Send Voice Messages"),
"send_polls": _("Create Polls"),
"use_external_apps": _("Use External Apps"),
} }
DANGEROUS_COMMANDS = { DANGEROUS_COMMANDS = {

View File

@ -445,7 +445,6 @@ class Filter(commands.Cog):
async def filter_hits( async def filter_hits(
self, self,
text: str,
server_or_channel: Union[ server_or_channel: Union[
discord.Guild, discord.Guild,
discord.TextChannel, discord.TextChannel,
@ -453,6 +452,7 @@ class Filter(commands.Cog):
discord.StageChannel, discord.StageChannel,
discord.Thread, discord.Thread,
], ],
*texts: str,
) -> Set[str]: ) -> Set[str]:
if isinstance(server_or_channel, discord.Guild): if isinstance(server_or_channel, discord.Guild):
guild = server_or_channel guild = server_or_channel
@ -483,6 +483,7 @@ class Filter(commands.Cog):
self.pattern_cache[(guild.id, channel and channel.id)] = pattern self.pattern_cache[(guild.id, channel and channel.id)] = pattern
if pattern: if pattern:
for text in texts:
hits |= set(pattern.findall(text)) hits |= set(pattern.findall(text))
return hits return hits
@ -506,7 +507,15 @@ class Filter(commands.Cog):
user_count = 0 user_count = 0
member_data["filter_count"] = user_count member_data["filter_count"] = user_count
hits = await self.filter_hits(message.content, message.channel) texts = [message.content]
poll = message.poll
if poll is not None:
texts.append(poll.question or "")
for answer in poll.answers:
texts.append(answer.text or "")
for attachment in message.attachments:
texts.append(attachment.description or "")
hits = await self.filter_hits(message.channel, *texts)
if hits: if hits:
# modlog doesn't accept PartialMessageable # modlog doesn't accept PartialMessageable
@ -607,7 +616,7 @@ class Filter(commands.Cog):
await set_contextual_locales_from_guild(self.bot, guild) await set_contextual_locales_from_guild(self.bot, guild)
if await self.filter_hits(member.display_name, member.guild): if await self.filter_hits(member.guild, member.display_name):
name_to_use = guild_data["filter_default_name"] name_to_use = guild_data["filter_default_name"]
reason = _("Filtered nickname") if member.nick else _("Filtered name") reason = _("Filtered nickname") if member.nick else _("Filtered name")
try: try:

View File

@ -267,11 +267,13 @@ def parse_cli_flags(args):
) )
parser.add_argument( parser.add_argument(
"--team-members-are-owners", "--team-members-are-owners",
"--team-developers-are-owners",
action="store_true", action="store_true",
dest="use_team_features", dest="use_team_features",
default=False, default=False,
help=( help=(
"Treat application team members as owners. " "Treat application team members as owners, if their team role is Owner, "
"Admin, or Developer. "
"This is off by default. Owners can load and run arbitrary code. " "This is off by default. Owners can load and run arbitrary code. "
"Do not enable if you would not trust all of your team members with " "Do not enable if you would not trust all of your team members with "
"all of the data on the host machine." "all of the data on the host machine."

View File

@ -10,10 +10,12 @@ from discord.app_commands import (
AllChannels as AllChannels, AllChannels as AllChannels,
AppCommand as AppCommand, AppCommand as AppCommand,
AppCommandChannel as AppCommandChannel, AppCommandChannel as AppCommandChannel,
AppCommandContext as AppCommandContext,
AppCommandError as AppCommandError, AppCommandError as AppCommandError,
AppCommandGroup as AppCommandGroup, AppCommandGroup as AppCommandGroup,
AppCommandPermissions as AppCommandPermissions, AppCommandPermissions as AppCommandPermissions,
AppCommandThread as AppCommandThread, AppCommandThread as AppCommandThread,
AppInstallationType as AppInstallationType,
Argument as Argument, Argument as Argument,
BotMissingPermissions as BotMissingPermissions, BotMissingPermissions as BotMissingPermissions,
Command as Command, Command as Command,
@ -45,6 +47,8 @@ from discord.app_commands import (
TranslationContextTypes as TranslationContextTypes, TranslationContextTypes as TranslationContextTypes,
TranslationError as TranslationError, TranslationError as TranslationError,
Translator as Translator, Translator as Translator,
allowed_contexts as allowed_contexts,
allowed_installs as allowed_installs,
autocomplete as autocomplete, autocomplete as autocomplete,
check as check, check as check,
CheckFailure as CheckFailure, CheckFailure as CheckFailure,
@ -54,10 +58,14 @@ from discord.app_commands import (
context_menu as context_menu, context_menu as context_menu,
default_permissions as default_permissions, default_permissions as default_permissions,
describe as describe, describe as describe,
dm_only as dm_only,
guild_install as guild_install,
guild_only as guild_only, guild_only as guild_only,
guilds as guilds, guilds as guilds,
locale_str as locale_str, locale_str as locale_str,
private_channel_only as private_channel_only,
rename as rename, rename as rename,
user_install as user_install,
) )
from . import checks as checks from . import checks as checks
@ -66,10 +74,12 @@ __all__ = (
"AllChannels", "AllChannels",
"AppCommand", "AppCommand",
"AppCommandChannel", "AppCommandChannel",
"AppCommandContext",
"AppCommandError", "AppCommandError",
"AppCommandGroup", "AppCommandGroup",
"AppCommandPermissions", "AppCommandPermissions",
"AppCommandThread", "AppCommandThread",
"AppInstallationType",
"Argument", "Argument",
"BotMissingPermissions", "BotMissingPermissions",
"Command", "Command",
@ -101,6 +111,8 @@ __all__ = (
"TranslationContextTypes", "TranslationContextTypes",
"TranslationError", "TranslationError",
"Translator", "Translator",
"allowed_contexts",
"allowed_installs",
"autocomplete", "autocomplete",
"check", "check",
"CheckFailure", "CheckFailure",
@ -110,9 +122,13 @@ __all__ = (
"context_menu", "context_menu",
"default_permissions", "default_permissions",
"describe", "describe",
"dm_only",
"guild_install",
"guild_only", "guild_only",
"guilds", "guilds",
"locale_str", "locale_str",
"private_channel_only",
"rename", "rename",
"user_install",
"checks", "checks",
) )

View File

@ -1257,7 +1257,11 @@ class Red(
def _setup_owners(self) -> None: def _setup_owners(self) -> None:
if self.application.team: if self.application.team:
if self._use_team_features: if self._use_team_features:
self.owner_ids.update(m.id for m in self.application.team.members) self.owner_ids.update(
m.id
for m in self.application.team.members
if m.role in (discord.TeamMemberRole.admin, discord.TeamMemberRole.developer)
)
elif self._owner_id_overwrite is None: elif self._owner_id_overwrite is None:
self.owner_ids.add(self.application.owner.id) self.owner_ids.add(self.application.owner.id)

View File

@ -2848,21 +2848,12 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
ctx.bot.description = description ctx.bot.description = description
await ctx.tick() await ctx.tick()
@_set_bot.group(name="avatar", invoke_without_command=True) async def _set_bot_image(
@commands.is_owner() self,
async def _set_bot_avatar(self, ctx: commands.Context, url: str = None): image_type: Literal["avatar", "banner"],
"""Sets [botname]'s avatar ctx: commands.Context,
url: Optional[str] = None,
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.
"""
if len(ctx.message.attachments) > 0: # Attachments take priority if len(ctx.message.attachments) > 0: # Attachments take priority
data = await ctx.message.attachments[0].read() data = await ctx.message.attachments[0].read()
elif url is not None: elif url is not None:
@ -2883,20 +2874,49 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
try: try:
async with ctx.typing(): async with ctx.typing():
if image_type == "avatar":
await ctx.bot.user.edit(avatar=data) await ctx.bot.user.edit(avatar=data)
else:
await ctx.bot.user.edit(banner=data)
except discord.HTTPException: except discord.HTTPException:
if image_type == "avatar":
await ctx.send( await ctx.send(
_( _(
"Failed. Remember that you can edit my avatar " "Failed. Remember that you can edit my avatar "
"up to two times a hour. The URL or attachment " "up to two times a hour. The URL or attachment "
"must be a valid image in either JPG, PNG, or GIF format." "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: except ValueError:
await ctx.send(_("JPG / PNG / GIF format only.")) await ctx.send(_("JPG / PNG / GIF / WEBP format only."))
else: else:
await ctx.send(_("Done.")) 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"]) @_set_bot_avatar.command(name="remove", aliases=["clear"])
@commands.is_owner() @commands.is_owner()
async def _set_bot_avatar_remove(self, ctx: commands.Context): 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.bot.user.edit(avatar=None)
await ctx.send(_("Avatar removed.")) 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"]) @_set_bot.command(name="username", aliases=["name"])
@commands.is_owner() @commands.is_owner()
async def _set_bot_username(self, ctx: commands.Context, *, username: str): async def _set_bot_username(self, ctx: commands.Context, *, username: str):

View File

@ -20,7 +20,7 @@ click==8.1.7
# via -r base.in # via -r base.in
contextlib2==21.6.0 contextlib2==21.6.0
# via schema # via schema
discord-py==2.3.2 discord-py==2.4.0
# via # via
# -r base.in # -r base.in
# red-lavalink # red-lavalink