Exemplo n.º 1
0
    async def whois(self, ctx, user):
        if ctx.message.mentions:
            user = ctx.message.mentions[0].id

        user = await self.client.fetch_user(int(user))

        if user is None:
            return

        embed = discord.Embed(colour=discord.Colour.blue())

        embed.set_author(name=user.display_name, icon_url=user.avatar_url)
        embed.add_field(name="Discriminator",
                        value="#{}".format(user.discriminator))
        embed.add_field(name="Discord Id", value=user.id)
        embed.add_field(name="Bot", value="Nee" if not user.bot else "Ja")

        created_local = timeFormatters.epochToDate(user.created_at.timestamp())

        embed.add_field(name="Account Aangemaakt",
                        value="{}\n({} geleden)".format(
                            created_local["date"],
                            timeFormatters.diffYearBasisString(
                                round(created_local["dateDT"].timestamp()))),
                        inline=False)

        # Check if the user is in the current guild
        if ctx.guild is not None:
            member_instance = ctx.guild.get_member(user.id)

            embed.add_field(name="Lid van {}".format(ctx.guild.name),
                            value="Nee" if member_instance is None else "Ja")

            if member_instance is not None:
                joined_local = timeFormatters.epochToDate(
                    member_instance.joined_at.timestamp())

                embed.add_field(
                    name="Lid Geworden Op",
                    value="{}\n({} Geleden)".format(
                        joined_local["date"],
                        timeFormatters.diffYearBasisString(
                            round(joined_local["dateDT"].timestamp()))))

                embed.add_field(name="Mention String",
                                value=member_instance.mention,
                                inline=False)

        await ctx.send(embed=embed)
Exemplo n.º 2
0
    async def trends(self, ctx, country: str = "Belgium"):
        """
        Command that gives more precise stats & changes.
        :param ctx: Discord Context
        :param country: the country to get the stats for
        """
        dic = await self.getCountryStats(country)
        if dic is None:
            await self.sendError(ctx)
            return

        # Get the distribution for this country
        distribution = self.distribution(dic)

        embed = discord.Embed(colour=discord.Colour.red(),
                              title="Coronatrends {}".format(
                                  dic["today"]["country"]))
        embed.set_thumbnail(url="https://i.imgur.com/aWnDuBt.png")

        # Calculate the trends & add them into the fields
        embed.add_field(name="Totale Gevallen\n({:,})".format(
            dic["today"]["cases"]),
                        value=self.trend(dic, "cases"),
                        inline=True)

        embed.add_field(name="Sterfgevallen\n({:,})".format(
            dic["today"]["deaths"]),
                        value=self.trend(dic, "deaths"),
                        inline=True)

        embed.add_field(name="Hersteld\n({:,})".format(
            dic["today"]["recovered"]),
                        value=self.trend(dic, "recovered"))

        embed.add_field(name="Totale Gevallen\nVandaag ({:,})".format(
            dic["today"]["todayCases"]),
                        value=self.trend(dic, "todayCases"),
                        inline=True)

        embed.add_field(name="Sterfgevallen\nVandaag ({:,})".format(
            dic["today"]["todayDeaths"]),
                        value=self.trend(dic, "todayDeaths"),
                        inline=True)

        embed.add_field(name="Hersteld\nVandaag ({:,})".format(
            dic["today"]["todayRecovered"]),
                        value=self.trend(dic, "todayRecovered"))

        embed.add_field(
            name="Verdeling",
            value="Actief: {} | Overleden: {} | Hersteld: {}".format(
                distribution[0], distribution[1], distribution[2]),
            inline=False)

        # Timestamp of last update
        timeFormatted = timeFormatters.epochToDate(
            int(dic["today"]["updated"]) / 1000)
        embed.set_footer(text="Laatst geüpdatet op {} ({} geleden)".format(
            timeFormatted["date"], timeFormatted["timeAgo"]))
        await ctx.send(embed=embed)
Exemplo n.º 3
0
    async def current(self, ctx):
        p = poke.get()
        pokedTimeStamp = timeFormatters.epochToDate(int(p[1]))["dateDT"]
        timeString = timeFormatters.diffDayBasisString(pokedTimeStamp)

        await ctx.send("Het is al **{}** aan **{}**.".format(
            timeString, self.utilsCog.getDisplayName(ctx, p[0])))
Exemplo n.º 4
0
 def formatTime(self, timestamp):
     if int(timestamp) <= 86400:
         minutes = int(timestamp) // 60
         if minutes < 60:
             return str(minutes) + "m"
         return "{}h{:02}m".format(minutes // 60, minutes % 60)
     else:
         return timeFormatters.epochToDate(int(timestamp), "%H:%M")["date"]
Exemplo n.º 5
0
    async def sendEmbed(self, ctx, dic):
        """
        Function that sends a Corona embed from a dictionary.
        :param ctx: Discord Context
        :param dic: the dictionary corresponding to this country
        """
        embed = discord.Embed(colour=discord.Colour.red(),
                              title="Coronatracker {}".format(
                                  dic["today"]["country"]))
        embed.set_thumbnail(url="https://i.imgur.com/aWnDuBt.png")

        # Total
        embed.add_field(name="Totale Gevallen (Vandaag):",
                        value="{:,} **(+{:,})** {}".format(
                            dic["today"]["cases"], dic["today"]["todayCases"],
                            self.trendIndicator(dic, "todayCases")),
                        inline=False)

        # Active
        embed.add_field(
            name="Actieve Gevallen (Vandaag):",
            value="{:,} **(+{:,})** {}".format(
                dic["today"]["activeCases"],
                dic["today"]["activeCases"] - dic["yesterday"]["activeCases"],
                self.activeTrendIndicator(dic)),
            inline=False)

        # Deaths
        embed.add_field(name="Sterfgevallen (Vandaag):",
                        value="{:,} **(+{:,})** {}".format(
                            dic["today"]["deaths"],
                            dic["today"]["todayDeaths"],
                            self.trendIndicator(dic, "todayDeaths")),
                        inline=False)

        # Recovered
        embed.add_field(name="Hersteld (Vandaag):",
                        value="{:,} **(+{:,}) {}**".format(
                            dic["today"]["recovered"],
                            dic["today"]["todayRecovered"],
                            self.trendIndicator(dic, "todayRecovered")),
                        inline=False)

        # Test Cases
        embed.add_field(name="Aantal uitgevoerde tests:",
                        value="{:,}".format(dic["today"]["tests"]),
                        inline=False)

        # Timestamp of last update
        timeFormatted = timeFormatters.epochToDate(
            int(dic["today"]["updated"]) / 1000)
        embed.set_footer(text="Laatst geüpdatet op {} ({} geleden)".format(
            timeFormatted["date"], timeFormatted["timeAgo"]))
        await ctx.send(embed=embed)