Example #1
0
    async def slowmode(
        self, ctx: commands.Context, *,
        time: UserFriendlyTime(converter=commands.TextChannelConverter,
                               default=False,
                               assume_reason=True)
    ) -> None:
        """Enables slowmode, max 6h

        Examples:
        !!slowmode 2h
        !!slowmode 2h #general
        !!slowmode off
        !!slowmode 0s #general
        """
        duration = timedelta()
        channel = ctx.channel
        if time.dt:
            duration = time.dt - ctx.message.created_at
        if time.arg:
            if isinstance(time.arg, str):
                try:
                    channel = await commands.TextChannelConverter().convert(
                        ctx, time.arg)
                except commands.BadArgument:
                    if time.arg != 'off':
                        raise
            else:
                channel = time.arg

        seconds = int(duration.total_seconds())

        if seconds > 21600:
            await ctx.send('Slowmode only supports up to 6h max at the moment')
        else:
            fmt = format_timedelta(duration, assume_forever=False)
            await channel.edit(slowmode_delay=int(duration.total_seconds()))
            await self.send_log(ctx, channel, fmt)
            if duration.total_seconds():
                await ctx.send(f'Enabled `{fmt}` slowmode on {channel.mention}'
                               )
            else:
                await ctx.send(f'Disabled slowmode on {channel.mention}')
Example #2
0
        async def timestamp(created):
            delta = format_timedelta(ctx.message.created_at - created)
            guild_config = await self.bot.db.get_guild_config(ctx.guild.id)
            created += timedelta(hours=guild_config.time_offset)

            return f"{delta} ago ({created.strftime('%H:%M:%S')})"
Example #3
0
        async def timestamp(created):
            delta = format_timedelta(ctx.message.created_at - created)
            offset = (await ctx.guild_config()).get('time_offset', 0)
            created += timedelta(hours=offset)

            return f"{delta} ago ({created.strftime('%H:%M:%S')})"