mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Make use of dpy commands.Range on set status commands (#6227)
This commit is contained in:
parent
9e23c3a5b8
commit
a06a704365
@ -3032,7 +3032,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
)
|
)
|
||||||
@commands.bot_in_a_guild()
|
@commands.bot_in_a_guild()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def _set_status_stream(self, ctx: commands.Context, streamer=None, *, stream_title=None):
|
async def _set_status_stream(
|
||||||
|
self,
|
||||||
|
ctx: commands.Context,
|
||||||
|
streamer: commands.Range[str, 1, 489] = None,
|
||||||
|
*,
|
||||||
|
stream_title: commands.Range[str, 1, 128] = None,
|
||||||
|
):
|
||||||
"""Sets [botname]'s streaming status to a twitch stream.
|
"""Sets [botname]'s streaming status to a twitch stream.
|
||||||
|
|
||||||
This will appear as `Streaming <stream_title>` or `LIVE ON TWITCH` depending on the context.
|
This will appear as `Streaming <stream_title>` or `LIVE ON TWITCH` depending on the context.
|
||||||
@ -3056,12 +3062,6 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
stream_title = stream_title.strip()
|
stream_title = stream_title.strip()
|
||||||
if "twitch.tv/" not in streamer:
|
if "twitch.tv/" not in streamer:
|
||||||
streamer = "https://www.twitch.tv/" + 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)
|
activity = discord.Streaming(url=streamer, name=stream_title)
|
||||||
await ctx.bot.change_presence(status=status, activity=activity)
|
await ctx.bot.change_presence(status=status, activity=activity)
|
||||||
elif streamer is not None:
|
elif streamer is not None:
|
||||||
@ -3074,7 +3074,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
@_set_status.command(name="playing", aliases=["game"])
|
@_set_status.command(name="playing", aliases=["game"])
|
||||||
@commands.bot_in_a_guild()
|
@commands.bot_in_a_guild()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def _set_status_game(self, ctx: commands.Context, *, game: str = None):
|
async def _set_status_game(
|
||||||
|
self, ctx: commands.Context, *, game: commands.Range[str, 1, 128] = None
|
||||||
|
):
|
||||||
"""Sets [botname]'s playing status.
|
"""Sets [botname]'s playing status.
|
||||||
|
|
||||||
This will appear as `Playing <game>` or `PLAYING A GAME: <game>` depending on the context.
|
This will appear as `Playing <game>` or `PLAYING A GAME: <game>` depending on the context.
|
||||||
@ -3090,9 +3092,6 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if game:
|
if game:
|
||||||
if len(game) > 128:
|
|
||||||
await ctx.send(_("The maximum length of game descriptions is 128 characters."))
|
|
||||||
return
|
|
||||||
game = discord.Game(name=game)
|
game = discord.Game(name=game)
|
||||||
else:
|
else:
|
||||||
game = None
|
game = None
|
||||||
@ -3106,7 +3105,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
@_set_status.command(name="listening")
|
@_set_status.command(name="listening")
|
||||||
@commands.bot_in_a_guild()
|
@commands.bot_in_a_guild()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def _set_status_listening(self, ctx: commands.Context, *, listening: str = None):
|
async def _set_status_listening(
|
||||||
|
self, ctx: commands.Context, *, listening: commands.Range[str, 1, 128] = None
|
||||||
|
):
|
||||||
"""Sets [botname]'s listening status.
|
"""Sets [botname]'s listening status.
|
||||||
|
|
||||||
This will appear as `Listening to <listening>`.
|
This will appear as `Listening to <listening>`.
|
||||||
@ -3123,11 +3124,6 @@ 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
|
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
|
||||||
if listening:
|
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)
|
activity = discord.Activity(name=listening, type=discord.ActivityType.listening)
|
||||||
else:
|
else:
|
||||||
activity = None
|
activity = None
|
||||||
@ -3142,7 +3138,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
@_set_status.command(name="watching")
|
@_set_status.command(name="watching")
|
||||||
@commands.bot_in_a_guild()
|
@commands.bot_in_a_guild()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def _set_status_watching(self, ctx: commands.Context, *, watching: str = None):
|
async def _set_status_watching(
|
||||||
|
self, ctx: commands.Context, *, watching: commands.Range[str, 1, 128] = None
|
||||||
|
):
|
||||||
"""Sets [botname]'s watching status.
|
"""Sets [botname]'s watching status.
|
||||||
|
|
||||||
This will appear as `Watching <watching>`.
|
This will appear as `Watching <watching>`.
|
||||||
@ -3159,9 +3157,6 @@ 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
|
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
|
||||||
if watching:
|
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)
|
activity = discord.Activity(name=watching, type=discord.ActivityType.watching)
|
||||||
else:
|
else:
|
||||||
activity = None
|
activity = None
|
||||||
@ -3174,7 +3169,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
@_set_status.command(name="competing")
|
@_set_status.command(name="competing")
|
||||||
@commands.bot_in_a_guild()
|
@commands.bot_in_a_guild()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def _set_status_competing(self, ctx: commands.Context, *, competing: str = None):
|
async def _set_status_competing(
|
||||||
|
self, ctx: commands.Context, *, competing: commands.Range[str, 1, 128] = None
|
||||||
|
):
|
||||||
"""Sets [botname]'s competing status.
|
"""Sets [botname]'s competing status.
|
||||||
|
|
||||||
This will appear as `Competing in <competing>`.
|
This will appear as `Competing in <competing>`.
|
||||||
@ -3191,11 +3188,6 @@ 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
|
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
|
||||||
if competing:
|
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)
|
activity = discord.Activity(name=competing, type=discord.ActivityType.competing)
|
||||||
else:
|
else:
|
||||||
activity = None
|
activity = None
|
||||||
@ -3210,7 +3202,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
@_set_status.command(name="custom")
|
@_set_status.command(name="custom")
|
||||||
@commands.bot_in_a_guild()
|
@commands.bot_in_a_guild()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def _set_status_custom(self, ctx: commands.Context, *, text: str = None):
|
async def _set_status_custom(
|
||||||
|
self, ctx: commands.Context, *, text: commands.Range[str, 1, 128] = None
|
||||||
|
):
|
||||||
"""Sets [botname]'s custom status.
|
"""Sets [botname]'s custom status.
|
||||||
|
|
||||||
This will appear as `<text>`.
|
This will appear as `<text>`.
|
||||||
@ -3227,9 +3221,6 @@ 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
|
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
|
||||||
if text:
|
if text:
|
||||||
if len(text) > 128:
|
|
||||||
await ctx.send(_("The maximum length of custom statuses is 128 characters."))
|
|
||||||
return
|
|
||||||
activity = discord.Activity(name=text, state=text, type=discord.ActivityType.custom)
|
activity = discord.Activity(name=text, state=text, type=discord.ActivityType.custom)
|
||||||
else:
|
else:
|
||||||
activity = None
|
activity = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user