mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-22 02:37:57 -05:00
Merge branch 'V3/develop' into cog_guide_core
# Conflicts: # redbot/core/core_commands.py
This commit is contained in:
@@ -172,6 +172,20 @@ class CoreLogic:
|
||||
except errors.CogLoadError as e:
|
||||
failed_with_reason_packages.append((name, str(e)))
|
||||
except Exception as e:
|
||||
if isinstance(e, commands.CommandRegistrationError):
|
||||
if e.alias_conflict:
|
||||
error_message = _(
|
||||
"Alias {alias_name} is already an existing command"
|
||||
" or alias in one of the loaded cogs."
|
||||
).format(alias_name=inline(e.name))
|
||||
else:
|
||||
error_message = _(
|
||||
"Command {command_name} is already an existing command"
|
||||
" or alias in one of the loaded cogs."
|
||||
).format(command_name=inline(e.name))
|
||||
failed_with_reason_packages.append((name, error_message))
|
||||
continue
|
||||
|
||||
log.exception("Package loading failed", exc_info=e)
|
||||
|
||||
exception_log = "Exception during loading of package\n"
|
||||
@@ -2094,7 +2108,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
if game:
|
||||
if len(game) > 128:
|
||||
await ctx.send("The maximum length of game descriptions is 128 characters.")
|
||||
await ctx.send(_("The maximum length of game descriptions is 128 characters."))
|
||||
return
|
||||
game = discord.Game(name=game)
|
||||
else:
|
||||
@@ -2126,6 +2140,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
|
||||
if listening:
|
||||
if len(listening) > 128:
|
||||
await ctx.send(
|
||||
_("The maximum length of listening descriptions is 128 characters.")
|
||||
)
|
||||
return
|
||||
activity = discord.Activity(name=listening, type=discord.ActivityType.listening)
|
||||
else:
|
||||
activity = None
|
||||
@@ -2157,6 +2176,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
|
||||
if watching:
|
||||
if len(watching) > 128:
|
||||
await ctx.send(_("The maximum length of watching descriptions is 128 characters."))
|
||||
return
|
||||
activity = discord.Activity(name=watching, type=discord.ActivityType.watching)
|
||||
else:
|
||||
activity = None
|
||||
@@ -2186,6 +2208,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
|
||||
if competing:
|
||||
if len(competing) > 128:
|
||||
await ctx.send(
|
||||
_("The maximum length of competing descriptions is 128 characters.")
|
||||
)
|
||||
return
|
||||
activity = discord.Activity(name=competing, type=discord.ActivityType.competing)
|
||||
else:
|
||||
activity = None
|
||||
@@ -2234,11 +2261,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
await ctx.bot.change_presence(status=status, activity=game)
|
||||
await ctx.send(_("Status changed to {}.").format(status))
|
||||
|
||||
@_set.command(name="streaming", aliases=["stream"], usage="[(<streamer> <stream_title>)]")
|
||||
@_set.command(
|
||||
name="streaming", aliases=["stream", "twitch"], usage="[(<streamer> <stream_title>)]"
|
||||
)
|
||||
@checks.bot_in_a_guild()
|
||||
@checks.is_owner()
|
||||
async def stream(self, ctx: commands.Context, streamer=None, *, stream_title=None):
|
||||
"""Sets [botname]'s streaming status.
|
||||
"""Sets [botname]'s streaming status to a twitch stream.
|
||||
|
||||
This will appear as `Streaming <stream_title>` or `LIVE ON TWITCH` depending on the context.
|
||||
It will also include a `Watch` button with a twitch.tv url for the provided streamer.
|
||||
@@ -2262,6 +2291,12 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
stream_title = stream_title.strip()
|
||||
if "twitch.tv/" not in streamer:
|
||||
streamer = "https://www.twitch.tv/" + streamer
|
||||
if len(streamer) > 511:
|
||||
await ctx.send(_("The maximum length of the streamer url is 511 characters."))
|
||||
return
|
||||
if len(stream_title) > 128:
|
||||
await ctx.send(_("The maximum length of the stream title is 128 characters."))
|
||||
return
|
||||
activity = discord.Streaming(url=streamer, name=stream_title)
|
||||
await ctx.bot.change_presence(status=status, activity=activity)
|
||||
elif streamer is not None:
|
||||
@@ -2782,6 +2817,22 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
else:
|
||||
await ctx.send(_("Help will filter hidden commands."))
|
||||
|
||||
@helpset.command(name="showaliases")
|
||||
async def helpset_showaliases(self, ctx: commands.Context, show_aliases: bool = None):
|
||||
"""
|
||||
This allows the help command to show existing commands aliases if there is any.
|
||||
|
||||
This defaults to True.
|
||||
Using this without a setting will toggle.
|
||||
"""
|
||||
if show_aliases is None:
|
||||
show_aliases = not await ctx.bot._config.help.show_aliases()
|
||||
await ctx.bot._config.help.show_aliases.set(show_aliases)
|
||||
if show_aliases:
|
||||
await ctx.send(_("Help will show commands aliases."))
|
||||
else:
|
||||
await ctx.send(_("Help will not show commands aliases."))
|
||||
|
||||
@helpset.command(name="usetick")
|
||||
async def helpset_usetick(self, ctx: commands.Context, use_tick: bool = None):
|
||||
"""
|
||||
@@ -3275,8 +3326,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
"""
|
||||
uids = {getattr(user, "id", user) for user in users}
|
||||
await self.bot._whiteblacklist_cache.add_to_whitelist(None, uids)
|
||||
|
||||
await ctx.send(_("Users added to allowlist."))
|
||||
if len(users) > 1:
|
||||
await ctx.send(_("Users have been added to the allowlist."))
|
||||
else:
|
||||
await ctx.send(_("User has been added to the allowlist."))
|
||||
|
||||
@allowlist.command(name="list")
|
||||
async def allowlist_list(self, ctx: commands.Context):
|
||||
@@ -3291,8 +3344,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
if not curr_list:
|
||||
await ctx.send("Allowlist is empty.")
|
||||
return
|
||||
|
||||
msg = _("Users on allowlist:")
|
||||
if len(curr_list) > 1:
|
||||
msg = _("Users on the allowlist:")
|
||||
else:
|
||||
msg = _("User on the allowlist:")
|
||||
for user in curr_list:
|
||||
msg += "\n\t- {}".format(user)
|
||||
|
||||
@@ -3316,8 +3371,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
"""
|
||||
uids = {getattr(user, "id", user) for user in users}
|
||||
await self.bot._whiteblacklist_cache.remove_from_whitelist(None, uids)
|
||||
|
||||
await ctx.send(_("Users have been removed from the allowlist."))
|
||||
if len(users) > 1:
|
||||
await ctx.send(_("Users have been removed from the allowlist."))
|
||||
else:
|
||||
await ctx.send(_("User has been removed from the allowlist."))
|
||||
|
||||
@allowlist.command(name="clear")
|
||||
async def allowlist_clear(self, ctx: commands.Context):
|
||||
@@ -3366,8 +3423,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
uids = {getattr(user, "id", user) for user in users}
|
||||
await self.bot._whiteblacklist_cache.add_to_blacklist(None, uids)
|
||||
|
||||
await ctx.send(_("User added to blocklist."))
|
||||
if len(users) > 1:
|
||||
await ctx.send(_("Users have been added to the blocklist."))
|
||||
else:
|
||||
await ctx.send(_("User has been added to the blocklist."))
|
||||
|
||||
@blocklist.command(name="list")
|
||||
async def blocklist_list(self, ctx: commands.Context):
|
||||
@@ -3382,8 +3441,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
if not curr_list:
|
||||
await ctx.send("Blocklist is empty.")
|
||||
return
|
||||
|
||||
msg = _("Users on blocklist:")
|
||||
if len(curr_list) > 1:
|
||||
msg = _("Users on the blocklist:")
|
||||
else:
|
||||
msg = _("User on the blocklist:")
|
||||
for user in curr_list:
|
||||
msg += "\n\t- {}".format(user)
|
||||
|
||||
@@ -3405,8 +3466,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
"""
|
||||
uids = {getattr(user, "id", user) for user in users}
|
||||
await self.bot._whiteblacklist_cache.remove_from_blacklist(None, uids)
|
||||
|
||||
await ctx.send(_("Users have been removed from blocklist."))
|
||||
if len(users) > 1:
|
||||
await ctx.send(_("Users have been removed from the blocklist."))
|
||||
else:
|
||||
await ctx.send(_("User has been removed from the blocklist."))
|
||||
|
||||
@blocklist.command(name="clear")
|
||||
async def blocklist_clear(self, ctx: commands.Context):
|
||||
@@ -3468,7 +3531,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
@localallowlist.command(name="list")
|
||||
async def localallowlist_list(self, ctx: commands.Context):
|
||||
"""
|
||||
Lists users and roles on the server allowlist.
|
||||
Lists users and roles on the server allowlist.
|
||||
|
||||
Example:
|
||||
- `[p]localallowlist list`
|
||||
@@ -3478,8 +3541,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
if not curr_list:
|
||||
await ctx.send("Server allowlist is empty.")
|
||||
return
|
||||
|
||||
msg = _("Whitelisted Users and roles:")
|
||||
if len(curr_list) > 1:
|
||||
msg = _("Allowed users and/or roles:")
|
||||
else:
|
||||
msg = _("Allowed user or role:")
|
||||
for obj in curr_list:
|
||||
msg += "\n\t- {}".format(obj)
|
||||
|
||||
@@ -3593,8 +3658,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
if not curr_list:
|
||||
await ctx.send("Server blocklist is empty.")
|
||||
return
|
||||
|
||||
msg = _("Blacklisted Users and Roles:")
|
||||
if len(curr_list) > 1:
|
||||
msg = _("Blocked users and/or roles:")
|
||||
else:
|
||||
msg = _("Blocked user or role:")
|
||||
for obj in curr_list:
|
||||
msg += "\n\t- {}".format(obj)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user