mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Core] Add sensible character lengths to activity statuses (#4663)
* Add sensible character lengths * Add translation function Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
edbbd76b3c
commit
676f34185d
@ -1842,7 +1842,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:
|
||||
@ -1862,6 +1862,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
|
||||
@ -1881,6 +1886,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
|
||||
@ -1898,6 +1906,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
|
||||
@ -1938,11 +1951,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.
|
||||
|
||||
Leaving both streamer and stream_title empty will clear it."""
|
||||
|
||||
@ -1952,6 +1967,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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user