Ejemplo n.º 1
0
    def get_elapsed_time(self):
        """Returns a string containing the time that has passed since
        the news item was published

        """

        return utils.timedelta_to_string(datetime.now() - self.time)
Ejemplo n.º 2
0
    async def interval(self, ctx, *interval):
        """
        Manage automated backups for this server
        
        Get more help on the [wiki](https://wiki.xenon.bot/en/backups#automated-backups-interval).


        __Arguments__

        **interval**: The time between every backup or "off". (min 24h)
                    Supported units: hours(h), days(d), weeks(w)
                    Example: 1d 12h


        __Examples__

        ```{b.prefix}backup interval 24h```
        """
        if len(interval) > 0:
            await ctx.invoke("backup interval on " + " ".join(interval))
            return

        interval = await ctx.bot.db.intervals.find_one({
            "guild": ctx.guild_id,
            "user": ctx.author.id
        })
        if interval is None:
            raise ctx.f.INFO(
                "The **backup interval is** currently turned **off**.\n"
                f"Turn it on with `{ctx.bot.prefix}backup interval on 24h`.")

        else:
            raise ctx.f.INFO(
                embed={
                    "author": {
                        "name": "Backup Interval"
                    },
                    "fields":
                    [{
                        "name":
                        "Interval",
                        "value":
                        utils.timedelta_to_string(
                            timedelta(hours=interval["interval"])),
                        "inline":
                        True
                    }, {
                        "name": "Last Backup",
                        "value": utils.datetime_to_string(interval["last"]) +
                        " UTC",
                        "inline": False
                    }, {
                        "name": "Next Backup",
                        "value": utils.datetime_to_string(interval["next"]) +
                        " UTC",
                        "inline": False
                    }]
                })
Ejemplo n.º 3
0
    def get_eta_string(self):
        """Returns a string containing the alert's ETA

        """
        return utils.timedelta_to_string(self.expiry - datetime.now())
Ejemplo n.º 4
0
 async def _cmdf_uptime(self, substr, msg, privilege_level):
    """`{cmd}` - Get time since initialization."""
    buf = "**Bot current uptime:** {}. ".format(utils.timedelta_to_string(self.get_presence_timedelta()))
    await self._client.send_msg(msg, buf)
    return