async def rndactivity_add(self, ctx: commands.Context, game_type: Optional[ActivityTypeConverter], *, game: str): stream = None if game_type is None: game_type = discord.ActivityType.playing elif game_type == discord.ActivityType.streaming: game = game.split(" ") stream, game = game.pop(), " ".join(game) if not TWITCH_REGEX.match(stream): raise commands.BadArgument(translate("no_stream_provided")) activity = { "type": game_type.value, "game": game, "url": stream.strip("<>") if stream else None, } try: self.format_status(activity, error_deprecated=True) except KeyError as e: await ctx.send( warning( translate("parse_fail_invalid_placeholder", placeholder=str(e)))) else: async with self.config.statuses() as statuses: statuses.append(activity) await ctx.send( tick(translate("added_status", id=len(statuses))))
async def remindme(self, ctx: commands.Context, in_time: str, *, to: str): if len(to) > 1000: await ctx.send(translate("content_too_long")) return in_time = FutureTime.get_seconds(in_time) if in_time is None or in_time < 60: raise commands.BadArgument(translate("invalid_time")) reminder = await Reminder.create(ctx.author, to, in_time) if await ctx.embed_requested(): embed = discord.Embed( colour=await ctx.embed_colour(), description=reminder.message, title=translate("reminder_created"), timestamp=reminder.due_on, ) embed.set_footer(text=translate("will_send_on")) await ctx.send(embed=embed) else: await ctx.send( tick( translate( "reminder_set", date=Humanize(reminder.due_on, format="long", tzinfo=get_localzone()), )))
async def maintenance_disable(self, ctx: commands.Context): if os.environ.get("RED_MAINTENANCE"): await ctx.send(warning(translate("set_by_env"))) return manager.bot = False await self.config.maintenance.set_raw("global", value=False) await ctx.send(tick(translate("disabled")))
async def quote_remove(self, ctx: commands.Context, quote: Quote): await quote.ensure_can_modify(ctx.author) if await confirm(ctx, content=warning(translate("delete_confirmation"))): await quote.delete() await ctx.send(tick(translate("quote_deleted"))) else: await ctx.send(translate("op_cancelled"))
async def rndactivity_clear(self, ctx: commands.Context): amount = len(await self.config.statuses()) if await confirm(ctx, content=translate("clear_confirm", amount=amount)): await self.config.statuses.set([]) await self.bot.change_presence(activity=None, status=self.bot.guilds[0].me.status) await ctx.send(tick(translate("clear_success", amount=amount))) else: await ctx.send(translate("ok_then"))
async def edit_author(self, ctx: commands.Context, quote: Quote, *, author: discord.Member): await quote.ensure_can_modify(ctx.author) quote.message_author = author await quote.save() await ctx.send( tick( translate("quote_attributed", id=int(quote), member=str(author))))
async def rndactivity_remove(self, ctx: commands.Context, status: int): async with self.config.statuses() as statuses: if len(statuses) < status: return await ctx.send( warning(translate("non_existant_status", id=status))) removed = statuses.pop(status - 1) if not statuses: await self.bot.change_presence(activity=None, status=getattr( ctx.me, "status", None)) removed = escape(self.extract_status(removed)[1], mass_mentions=True) await ctx.send( tick(translate("status_removed", id=status, status=removed)))
async def quote_message(self, ctx: commands.Context, message: int, channel: discord.TextChannel = None): channel = channel or ctx.channel try: message = await channel.get_message(message) except discord.NotFound: await ctx.send(warning(translate("message_not_found"))) except discord.Forbidden: await ctx.send(warning(translate("message_forbidden"))) else: quote = await Quote.create(message.content, ctx.author, message.author) await ctx.send(tick(translate("quote_added")), embed=quote.embed)
async def timedmute( self, ctx: commands.Context, member: discord.Member, duration: TimeConverter, *, reason: str = None, ): from timedrole.api import TempRole if not await hierarchy_allows(self.bot, mod=ctx.author, member=member): await ctx.send(warning(translate("hierarchy_disallows"))) return role = await self.get_punished_role(ctx.guild) if role is None: tmp_msg = await ctx.send(translate("setting_up")) async with ctx.typing(): role = await self.setup_role(ctx.guild) await tmp_msg.delete() if role in member.roles: await ctx.send(warning(translate("already_muted"))) return role = await TempRole.create( member, role, duration=duration, added_by=ctx.author, reason=reason ) await role.apply_role(reason=reason) try: await modlog.create_case( bot=self.bot, guild=ctx.guild, user=member, moderator=ctx.author, reason=reason, until=role.expires_at, action_type="timedmute", created_at=role.added_at, ) except RuntimeError: pass await ctx.send(tick(translate("member_muted", member=member, duration=Humanize(duration))))
async def rndactivity_delay(self, ctx: commands.Context, *, duration: Delay): await self.config.delay.set(duration.total_seconds()) await ctx.send( tick(translate("delay_set", duration=Humanize(duration))))
async def maintenance_enable(self, ctx: commands.Context, *, message: str = None): manager.bot = message or True await self.config.maintenance.set_raw("global", value=message or True) await ctx.send(tick(translate("enabled")))
async def quote_add(self, ctx: commands.Context, *, message: str): quote = await Quote.create(message, ctx.author, ctx.author) await ctx.send(tick(translate("quote_added")), embed=quote.embed)
async def clear(self, ctx: commands.Context): if await confirm(ctx, content=translate("confirm_clear")): await self.config.user(ctx.author).reminders.set([]) await ctx.send(tick(translate("reminders_cleared"))) else: await ctx.send(translate("ok_then"))