Example #1
0
 async def about(self, ctx):
     lang = await self.bot.getg_lang(str(ctx.guild.id))
     embed = discord.Embed(
         timestamp=dctt(),
         color=self.bot.color,
         description=self.bot.locales[lang]["about_description"])
     nb_users = 0
     channels = 0
     for s in self.bot.guilds:
         nb_users += len(s.members)
         channels += len(s.channels)
     embed.add_field(name="Dashboard",
                     value="[lyvego.com](https://lyvego.com/)")
     embed.add_field(name="<:servers:693053697453850655> Servers",
                     value=len(self.bot.guilds))
     embed.add_field(name="<:users:693053423494365214> Members",
                     value=nb_users)
     embed.add_field(name="<:hashtag:693056105076621342> Channels",
                     value=channels)
     embed.add_field(
         name="<:stack:693054261512110091> Shards",
         value=f"{ctx.guild.shard_id + 1}/{self.bot.shard_count}")
     embed.add_field(
         name="πŸ’— Hearthbeat shards avg",
         value=
         f"`{sum([x[1] for x in self.bot.latencies]) / self.bot.shard_count:.3f}` ms"
     )
     await ctx.send(embed=embed)
     try:
         await ctx.message.add_reaction(
             "<a:valid_checkmark:709737579460952145>")
     except:
         pass
Example #2
0
 async def events(self, ctx):
     embed = discord.Embed(title="Events informations",
                           color=self.bot.color,
                           timestamp=dctt())
     embed.add_field(name="Last live", value=self._last_live)
     embed.add_field(name="Last clip", value=self._last_clip)
     embed.add_field(name="Last follow", value=self._last_follow)
     await ctx.send(embed=embed)
Example #3
0
 async def dashboard(self, ctx: commands.Context):
     embed = discord.Embed(title="Lyvego Dashboard",
                           description="[lyvego.com](https://lyvego.com/)",
                           timestamp=dctt(),
                           color=self.bot.color)
     embed.set_footer(text="lyvego.com", icon_url=ctx.me.avatar_url)
     await ctx.send(embed=embed)
     try:
         await ctx.message.add_reaction(
             "<a:valid_checkmark:709737579460952145>")
     except:
         pass
Example #4
0
    async def on_guild_join(self, guild: discord.Guild):
        try:
            acc = 0
            backoff_time = 2
            r = await self.http_session.request(
                method="POST",
                url="https://api.lyvego.com/v1/bot/server",
                headers={"Authorization": AUTHORIZATION},
                json={
                    "discord_id": guild.id,
                    "owner_id": guild.owner_id,
                    "name": guild.name,
                    "icon": guild.icon_url._url,
                    "region": guild.region.name
                }
            )
            while r.status not in range(200, 300) and acc < MAX_RETRIES:
                r = await self.http_session.request(
                    method="POST",
                    url="https://api.lyvego.com/v1/bot/server",
                    headers={"Authorization": AUTHORIZATION},
                    json={
                        "discord_id": guild.id,
                        "owner_id": guild.owner_id,
                        "name": guild.name,
                        "icon": guild.icon_url._url,
                        "region": guild.region.name
                    }
                )
                await asyncio.sleep(backoff_time)
                backoff_time *= 1.12
                acc += 1
        except:
            print(f"{guild.name} cannot be added to the DB", file=sys.stderr)

        chan_logger = self.get_channel(739633667906732143)
        embed = discord.Embed(
            title="Bot added to " + guild.name,
            timestamp=dctt(),
            color=self.color
        )
        embed.add_field(
            name="<:users:693053423494365214> Members",
            value=len(guild.members)
        )
        embed.add_field(
            name="<:hashtag:693056105076621342> Channels",
            value=len(guild.channels)
        )
        embed.set_thumbnail(url=guild.icon_url)
        embed.set_footer(icon_url=guild.me.avatar_url)
        await chan_logger.send(embed=embed)
Example #5
0
 async def _follow_event(self, events):
     for event in events:
         try:
             channel = self.bot.get_channel(int(event.channel))
             embed = discord.Embed(timestamp=dctt(),
                                   color=self.bot.blue,
                                   description=event.message)
             embed.set_author(name=f"{event.details.username}",
                              icon_url=event.details.avatar)
             embed.set_footer(text="New follow 💜")
             await channel.send(embed=embed)
         except:
             pass
Example #6
0
 async def ping(self, ctx):
     embed = discord.Embed(timestamp=dctt(),
                           color=self.bot.color,
                           title="Bot latency")
     embed.add_field(
         name="πŸ’— Hearthbeat",
         value=f"`{self.bot.latencies[ctx.guild.shard_id][1]:.3f}` ms")
     embed.set_footer(text="lyvego.com")
     await ctx.send(embed=embed)
     try:
         await ctx.message.add_reaction(
             "<a:valid_checkmark:709737579460952145>")
     except:
         pass
Example #7
0
 def on_live_embed(self, em, guild: discord.Guild):
     embed = discord.Embed(
         description=
         f"<:rec:703677659535769710> [{em.stream.name}]({em.stream.streamer.link})",
         color=int(f"0x{em.color}", 16),
         timestamp=dctt())
     embed.set_footer(icon_url=guild.me.avatar_url)
     embed.add_field(name="Viewer", value=em.stream.viewer)
     embed.add_field(name="Game", value=em.stream.game.name)
     embed.set_thumbnail(url=em.stream.game.icon)
     embed.set_author(name=em.stream.streamer.name,
                      url=em.stream.streamer.link,
                      icon_url=em.stream.streamer.avatar)
     embed.set_image(url=em.stream.thumbnail + f"?{time.time()}")
     embed.set_footer(text="lyvego.com")
     return embed
Example #8
0
 async def invite(self, ctx: commands.Context):
     lang = await self.bot.getg_lang(str(ctx.guild.id))
     embed = discord.Embed(
         title=self.bot.locales[lang]["title_invite_lyvego"],
         description=self.bot.locales[lang]
         ["description_invite_lyvego"].format(
             "https://discord.com/oauth2/authorize?client_id=702648685263323187&permissions=445504&redirect_uri=https%3A%2F%2Flyvego.com%2Flogin&response_type=code&scope=bot%20identify%20email%20guilds"
         ),
         timestamp=dctt(),
         color=self.bot.color)
     embed.set_footer(text="lyvego.com", icon_url=ctx.me.avatar_url)
     await ctx.send(embed=embed)
     try:
         await ctx.message.add_reaction(
             "<a:valid_checkmark:709737579460952145>")
     except:
         pass
Example #9
0
    async def _ban_event(self, events):
        for event in events:
            try:

                channel = self.bot.get_channel(int(event.channel))
                embed = discord.Embed(timestamp=dctt(),
                                      color=self.bot.red,
                                      description=event.message)
                embed.set_author(
                    name=f"Ban announce for {event.details.username}",
                    icon_url=
                    "https://cdn2.iconfinder.com/data/icons/superhero-neon-circle/64/1-superhero-512.png"
                )
                embed.set_thumbnail(url=event.details.avatar)
                embed.set_footer(text="Ban hammer 🔨")
                await channel.send(embed=embed)
            except Exception as e:
                logger.exception(e, exc_info=True)
Example #10
0
 async def _moderator_event(self, events):
     try:
         for event in events:
             try:
                 channel = self.bot.get_channel(int(event.channel))
                 embed = discord.Embed(timestamp=dctt(),
                                       description=event.message,
                                       color=self.bot.green)
                 embed.set_author(
                     name=f"New moderator for {event.details.username}",
                     icon_url=
                     "https://cdn4.iconfinder.com/data/icons/game-of-thrones-4/64/game_of_thrones_game_thrones_series_sword_weapon_lightbringer_fire-512.png"
                 )
                 embed.set_footer(text="New moderator")
                 await channel.send(embed=embed)
             except Exception as e:
                 logger.exception(e, exc_info=True)
     except Exception as e:
         logger.exception(e, exc_info=True)
Example #11
0
    async def help(self, ctx: commands.Context):
        lang = await self.bot.getg_lang(ctx.guild.id)
        react_list = [
            "<:lyvego:703585626053673060>", "<:twitch:703585214261231626>",
            "βš™οΈ"
        ]
        embed = discord.Embed(
            color=self.bot.color,
            description=self.bot.locales[lang]["help_description_header"],
            timestamp=dctt())
        embed.set_author(name=self.bot.locales[lang]["author_name_commands"],
                         icon_url=ctx.me.avatar_url)
        embed.add_field(
            name=self.bot.locales[lang]["help_hub_twitch"].format(
                react_list[1]),
            value=self.bot.locales[lang]["help_hub_tap_to_see"].format(
                react_list[1]),
            inline=False)
        embed.add_field(
            name=self.bot.locales[lang]["help_hub_settings"].format(
                react_list[2]),
            value=self.bot.locales[lang]["help_hub_tap_to_see"].format(
                react_list[2]),
            inline=False)
        embed.set_footer(text="lyvego.com | help pages deleted in 5 mins",
                         icon_url=ctx.me.avatar_url)
        pages = await ctx.send(embed=embed)

        for reaction in react_list:
            await pages.add_reaction(reaction)

        def predicate(reaction, user):
            return user == ctx.message.author and str(
                reaction.emoji) in react_list

        while True:
            try:
                reaction, user = await self.bot.wait_for('reaction_add',
                                                         check=predicate,
                                                         timeout=300.0)
            except asyncio.TimeoutError:
                try:
                    await ctx.message.delete()
                except:
                    pass
                await pages.delete()
                return

            if react_list[0] == str(reaction.emoji):
                embed = discord.Embed(color=self.bot.color,
                                      description=self.bot.locales[lang]
                                      ["help_description_header"],
                                      timestamp=dctt())
                embed.set_author(
                    name=self.bot.locales[lang]["author_name_commands"],
                    icon_url=ctx.me.avatar_url)
                embed.add_field(
                    name=self.bot.locales[lang]["help_hub_twitch"].format(
                        react_list[1]),
                    value=self.bot.locales[lang]["help_hub_tap_to_see"].format(
                        react_list[1]),
                    inline=False)
                embed.add_field(
                    name=self.bot.locales[lang]["help_hub_twitch"].format(
                        react_list[2]),
                    value=self.bot.locales[lang]["help_hub_tap_to_see"].format(
                        react_list[2]),
                    inline=False)
            elif react_list[1] == str(reaction.emoji):
                embed = discord.Embed(
                    timestamp=dctt(),
                    color=self.bot.color,
                )
                embed.set_author(name=self.bot.locales[lang]
                                 ["paginated_author_twitch_commands"],
                                 icon_url=ctx.me.avatar_url)
                embed.add_field(
                    name=
                    f"{ctx.prefix}stream <streamer_name> [message : Optional]",
                    value=self.bot.locales[lang]["help_streamer"],
                    inline=False)
                embed.add_field(
                    name=
                    f"{ctx.prefix}follow <streamer_name> [message : Optional]",
                    value=self.bot.locales[lang]["help_follow"],
                    inline=False)

                embed.add_field(
                    name=
                    f"{ctx.prefix}clips <streamer_name> [message : Optional]",
                    value=self.bot.locales[lang]["help_clips"],
                    inline=False)
                embed.add_field(
                    name=
                    f"{ctx.prefix}remove <follow | stream | clips> <streamer_name>",
                    value=self.bot.locales[lang]["help_remove"],
                    inline=False)

                embed.add_field(
                    name=f"{ctx.prefix}topclip <streamer_name> [amount]",
                    value=self.bot.locales[lang]["help_topclip"],
                    inline=False)

            elif react_list[2] == reaction.emoji:
                embed = discord.Embed(timestamp=dctt(), color=self.bot.color)
                embed.set_author(name=self.bot.locales[lang]
                                 ["paginated_author_settings_commands"],
                                 icon_url=ctx.me.avatar_url)
                embed.add_field(name=f"{ctx.prefix}setprefix <new_prefix>",
                                value=self.bot.locales[lang]["help_prefix"],
                                inline=False)
                embed.add_field(name=f"{ctx.prefix}getprefix",
                                value=self.bot.locales[lang]["help_getprefix"],
                                inline=False)
                embed.add_field(
                    name=f"{ctx.prefix}lang <--list | new_language>",
                    value=self.bot.locales[lang]["help_language"].format(
                        ", ".join([x.upper()
                                   for x in self.bot.locales]).rstrip(", ")),
                    inline=False)
                embed.add_field(name=f"{ctx.prefix}invite",
                                value=self.bot.locales[lang]["help_invite"],
                                inline=False)
                embed.add_field(name=f"{ctx.prefix}dashboard",
                                value=self.bot.locales[lang]["help_dashboard"],
                                inline=False)
                embed.add_field(name=f"{ctx.prefix}ping",
                                value=self.bot.locales[lang]["help_ping"],
                                inline=False)
                embed.add_field(name=f"{ctx.prefix}vote",
                                value=self.bot.locales[lang]["help_vote"],
                                inline=False)
                embed.add_field(name=f"{ctx.prefix}about",
                                value=self.bot.locales[lang]["help_about"],
                                inline=False)

            embed.set_footer(text="lyvego.com", icon_url=ctx.me.avatar_url)
            await pages.remove_reaction(reaction.emoji, user)
            await pages.edit(embed=embed)
Example #12
0
    async def help_error(self, ctx: commands.Context, error):
        lang = await self.bot.getg_lang(ctx.guild.id)
        # if isinstance(error, commands.MissingPermissions):
        #     await ctx.send(self.bot.locales[lang]["error_missing_manages_permissions"].format(ctx.author.mention))

        embed = discord.Embed(color=self.bot.color,
                              description=self.bot.locales[lang]
                              ["help_description_header"].format(
                                  self.bot.lyvego_url),
                              timestamp=dctt())
        embed.set_author(name=self.bot.locales[lang]["author_name_commands"],
                         icon_url=ctx.me.avatar_url)
        embed.add_field(
            name=
            f"<:twitch:703585214261231626> {ctx.prefix}stream <streamer_name>",
            value=self.bot.locales[lang]["help_streamer"],
            inline=False)
        embed.add_field(
            name=
            f"<:twitch:703585214261231626> {ctx.prefix}follow <streamer_name>",
            value=self.bot.locales[lang]["help_follow"],
            inline=False)
        embed.add_field(
            name=
            f"<:twitch:703585214261231626> {ctx.prefix}clips <streamer_name>",
            value=self.bot.locales[lang]["help_clips"],
            inline=False)
        embed.add_field(
            name=
            f"<:twitch:703585214261231626> {ctx.prefix}topclip <streamer_name> [amount]",
            value=self.bot.locales[lang]["help_topclip"],
            inline=False)
        embed.add_field(name=f"βš™οΈ {ctx.prefix}setprefix <new_prefix>",
                        value=self.bot.locales[lang]["help_prefix"],
                        inline=False)
        embed.add_field(name=f"βš™οΈ {ctx.prefix}lang <--list | new_language>",
                        value=self.bot.locales[lang]["help_language"].format(
                            ", ".join([x.upper() for x in self.bot.locales
                                       ]).rstrip(", ")),
                        inline=False)
        embed.add_field(name="βš™οΈ @Stream Alerts (Lyvego) getprefix",
                        value=self.bot.locales[lang]["help_getprefix"],
                        inline=False)
        embed.add_field(name=f"βš™οΈ {ctx.prefix}invite",
                        value=self.bot.locales[lang]["help_invite"],
                        inline=False)
        embed.add_field(name=f"βš™οΈ {ctx.prefix}dashboard",
                        value=self.bot.locales[lang]["help_dashboard"],
                        inline=False)
        embed.add_field(name=f"πŸ€– {ctx.prefix}ping",
                        value=self.bot.locales[lang]["help_ping"],
                        inline=False)
        embed.add_field(name=f"πŸ€– {ctx.prefix}vote",
                        value=self.bot.locales[lang]["help_vote"],
                        inline=False)
        embed.add_field(name=f"πŸ€– {ctx.prefix}about",
                        value=self.bot.locales[lang]["help_about"],
                        inline=False)
        embed.set_thumbnail(url=ctx.me.avatar_url)
        embed.set_footer(text="lyvego.com", icon_url=ctx.me.avatar_url)
        try:
            await ctx.message.add_reaction(
                "<a:valid_checkmark:709737579460952145>")
        except:
            pass
        await ctx.send(embed=embed)