Exemple #1
0
    async def time(self, ctx, *, offset: str = None):
        """Melihat local TimeZone milik mu atau member."""
        timezone = None
        if offset == None:
            member = ctx.message.author
        else:
            # Try to get a user first
            member = DisplayName.memberForName(offset, ctx.message.guild)

        if member:
            # We got one
            # Check for timezone first
            offset = self.settings.getGlobalUserStat(member, "TimeZone")
            memberName = DisplayName.memberForName(member, ctx.guild)
            if offset == None:
                offset = self.settings.getGlobalUserStat(member, "UTCOffset")

        if offset == None:
            msg = "*{}* belum mengatur local TimeZone.\n".format(
                memberName.mention)
            msg += "Cobalah merekomendasikannya untuk mengetik\n*`{}help settz`*\n\n".format(
                ctx.prefix)
            msg += "TimeZone *{}* saat ini ".format(memberName.mention)
            msg += "*{}* UTC.".format(
                UserTime.getClockForTime(
                    datetime.datetime.utcnow().strftime("%I:%M %p")))
            em = discord.Embed(color=0XFF8C00, description=msg)
            em.set_footer(
                text="Saat mengetik command, tanda [] tidak usah digunakan\n{}"
                .format(ctx.author),
                icon_url="{}".format(ctx.author.avatar_url))
            await ctx.channel.send(embed=em)
            return

        # At this point - we need to determine if we have an offset - or possibly a timezone passed
        t = self.getTimeFromTZ(offset)
        if t == None:
            # We did not get an offset
            t = self.getTimeFromOffset(offset)
            if t == None:
                msg = "┐( ̄ヘ ̄;)┌\nAku tidak dapat menemukan TimeZone yang kamu cari."
                em = discord.Embed(color=0XFF8C00, description=msg)
                em.set_footer(text="{}#{}".format(ctx.author),
                              icon_url="{}".format(ctx.author.avatar_url))
                await ctx.channel.send(embed=em)
                return
        t["time"] = UserTime.getClockForTime(t["time"])
        if member:
            msg = "local TimeZone {}\nBerada di *{}* saat ini jam *{}*".format(
                memberName.mention, t["zone"], t["time"])
        else:
            msg = "local TimeZone *{}* saat ini jam *{}*".format(
                t["zone"], t["time"])

        # Say message
        em = discord.Embed(color=0XFF8C00, description=msg)
        em.set_footer(text="{}".format(ctx.author),
                      icon_url="{}".format(ctx.author.avatar_url))
        await ctx.channel.send(embed=em)
Exemple #2
0
    async def time(self, ctx, *, offset: str = None):
        """Get UTC time +- an offset."""
        timezone = None
        if offset == None:
            member = ctx.message.author
        else:
            # Try to get a user first
            member = DisplayName.memberForName(offset, ctx.message.guild)

        if member:
            # We got one
            # Check for timezone first
            offset = self.settings.getGlobalUserStat(member, "TimeZone")
            if offset == None:
                offset = self.settings.getGlobalUserStat(member, "UTCOffset")

        if offset == None:
            msg = '*{}* hasn\'t set their TimeZone or offset yet - they can do so with the `{}setoffset [+-offset]` or `{}settz [Region/City]` command.\nThe current UTC time is *{}*.'.format(
                DisplayName.name(member), ctx.prefix, ctx.prefix,
                UserTime.getClockForTime(
                    datetime.datetime.utcnow().strftime("%I:%M %p")))
            await ctx.channel.send(msg)
            return

        # At this point - we need to determine if we have an offset - or possibly a timezone passed
        t = self.getTimeFromTZ(offset)
        if t == None:
            # We did not get an offset
            t = self.getTimeFromOffset(offset)
            if t == None:
                await ctx.channel.send(
                    "I couldn't find that TimeZone or offset!")
                return
        t["time"] = UserTime.getClockForTime(t["time"])
        if member:
            msg = '{}; where *{}* is, it\'s currently *{}*'.format(
                t["zone"], DisplayName.name(member), t["time"])
        else:
            msg = '{} is currently *{}*'.format(t["zone"], t["time"])

        # Say message
        await ctx.channel.send(msg)