Exemplo n.º 1
0
    async def embed_store_list(self, ctx: commands.Context):
        """
        View stored embeds.
        """
        db_config = await self.db_config()
        _embeds = db_config.get("embeds")
        if not _embeds:
            raise commands.BadArgument("There are no stored embeds.")

        description = [
            f"{index}. `{embed}`"
            for index, embed in enumerate(_embeds, start=1)
        ]
        description = "\n".join(description)

        color = self.bot.main_color
        em = discord.Embed(color=color, title=f"Stored Embeds")

        if len(description) > 2048:
            embeds = []
            pages = list(paginate(description, page_length=1024))
            for page in pages:
                embed = em.copy()
                embed.description = page
                embeds.append(embed)
            session = EmbedPaginatorSession(ctx, *embeds)
            await session.run()
        else:
            em.description = description
            await ctx.send(embed=em)
Exemplo n.º 2
0
    async def plugin_registry_compact(self, ctx):
        """Shows a compact view of all plugins within the registry."""

        await self.populate_registry()

        registry = sorted(self.registry.items(), key=lambda elem: elem[0])

        pages = [""]

        for name, details in registry:
            repo = f"https://github.com/{details['repository']}"
            url = f"{repo}/tree/{details['branch']}/{name}"
            desc = details["description"].replace("\n", "")
            fmt = f"[`{name}`]({url}) - {desc}"
            length = len(fmt) - len(url) - 4
            fmt = fmt[: 75 + len(url)].strip() + "..." if length > 75 else fmt
            if len(fmt) + len(pages[-1]) >= 2048:
                pages.append(fmt + "\n")
            else:
                pages[-1] += fmt + "\n"

        embeds = []

        for page in pages:
            embed = discord.Embed(color=self.bot.main_color, description=page)
            embed.set_author(name="Plugin Registry", icon_url=self.bot.user.avatar_url)
            embeds.append(embed)

        paginator = EmbedPaginatorSession(ctx, *embeds)
        await paginator.run()
Exemplo n.º 3
0
    async def trivia_list(self, ctx: commands.Context):
        """List available trivia categories."""
        lists = set(p.stem for p in self._all_lists())

        def base_embed(description: str = "", continued: bool = False):
            title = "Available trivia categories"
            if continued:
                title += " (Continued)"
            embed = discord.Embed(title=title,
                                  color=discord.Color.dark_theme(),
                                  description=description)
            len_list = len(lists)
            footer_text = f"Found {plural(len_list):trivia category|trivia categories}"
            embed.set_footer(text=footer_text)
            return embed

        embeds = [base_embed()]
        line = 1
        if lists:
            embed = embeds[0]
            for triv in sorted(lists):
                desc = f"`{triv}`\n"
                if line == 15:
                    embed = base_embed(desc, True)
                    embeds.append(embed)
                    line = 1
                else:
                    embed.description += desc
                    line += 1
        else:
            embeds[0].description = "There is no trivia category available."
        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 4
0
    async def members(self, ctx, *, role: typing.Union[discord.Role, str] = None):
        """Get info about a role"""

        embeds = RoleMembersResource(ctx, role).role_members_embed()

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 5
0
    async def logs(self, ctx, *, user: User = None):
        """
        Get previous Modmail thread logs of a member.

        Leave `user` blank when this command is used within a
        thread channel to show logs for the current recipient.
        `user` may be a user ID, mention, or name.
        """

        await ctx.trigger_typing()

        if not user:
            thread = ctx.thread
            if not thread:
                raise commands.MissingRequiredArgument(SimpleNamespace(name="member"))
            user = thread.recipient

        default_avatar = "https://cdn.discordapp.com/embed/avatars/0.png"
        icon_url = getattr(user, "avatar_url", default_avatar)

        logs = await self.bot.api.get_user_logs(user.id)

        if not any(not log["open"] for log in logs):
            embed = discord.Embed(
                color=discord.Color.red(),
                description="This user does not " "have any previous logs.",
            )
            return await ctx.send(embed=embed)

        logs = reversed([e for e in logs if not e["open"]])

        embeds = self.format_log_embeds(logs, avatar_url=icon_url)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 6
0
    async def logs_closed_by(self, ctx, *, user: User = None):
        """
        Get all logs closed by the specified user.

        If no `user` is provided, the user will be the person who sent this command.
        `user` may be a user ID, mention, or name.
        """
        user = user if user is not None else ctx.author

        query = {
            "guild_id": str(self.bot.guild_id),
            "open": False,
            "closer.id": str(user.id),
        }

        projection = {"messages": {"$slice": 5}}

        entries = await self.bot.db.logs.find(query, projection).to_list(None)

        embeds = self.format_log_embeds(entries, avatar_url=self.bot.guild.icon_url)

        if not embeds:
            embed = discord.Embed(
                color=discord.Color.red(),
                description="No log entries have been found for that query",
            )
            return await ctx.send(embed=embed)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 7
0
    async def logs_search(self, ctx, limit: Optional[int] = None, *, query):
        """
        Retrieve all logs that contain messages with your query.

        Provide a `limit` to specify the maximum number of logs the bot should find.
        """

        await ctx.trigger_typing()

        query = {
            "guild_id": str(self.bot.guild_id),
            "open": False,
            "$text": {"$search": f'"{query}"'},
        }

        projection = {"messages": {"$slice": 5}}

        entries = await self.bot.db.logs.find(query, projection).to_list(limit)

        embeds = self.format_log_embeds(entries, avatar_url=self.bot.guild.icon_url)

        if not embeds:
            embed = discord.Embed(
                color=discord.Color.red(),
                description="No log entries have been found for that query.",
            )
            return await ctx.send(embed=embed)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 8
0
 async def comandi(self, ctx):
     """Mostra i comandi del bot"""
     embed = discord.Embed(
         title="Tags",
         description=
         f"{ctx.prefix}tag <nome> - Usa un tag!\n{ctx.prefix}tags add <nome> <risposta> - Crea un tag!",
         color=discord.Color.green())
     embed1 = discord.Embed(
         title="Divertimento",
         description=
         f"{ctx.prefix}inspiro(bot) - Mostra un immagine a caso da InspiroBot.me\n{ctx.prefix}choose <primo oggetto> <secondo oggetto> Scegli tra 2 oggetti!\n{ctx.prefix}roll - Lancia un dado\n{ctx.prefix}flip - Lancia una moneta\n{ctx.prefix}rps - Sasso, Carta, o Forbici?\n{ctx.prefix}8ball <domanda>? - La 8Ball risponderà a ogni tua domanda!\n{ctx.prefix}reverse <messaggio> - !otseT out li etrevnI\n{ctx.prefix}meme - Ti da una meme a caso\n{ctx.prefix}roast <persona> - Insulta la persona menzionata\n{ctx.prefix}smallcaps <messaggio> - ᴄᴏɴᴠᴇʀᴛᴇ ɪʟ ᴛᴜᴏ ᴛᴇꜱᴛᴏ ᴀ ᴜɴ ᴍᴀɪᴜꜱᴄᴏʟᴏ ᴘɪᴄᴄᴏʟᴏ!",
         color=discord.Color.green())
     embed2 = discord.Embed(
         title="Hastebin",
         description=
         f"{ctx.prefix}hastebin <messaggio> - Inserisce il tuo testo su Hastebin",
         color=discord.Color.green())
     embed3 = discord.Embed(
         title="Benvenuto",
         description=
         f"{ctx.prefix}welcomer <chatincuiappareilmessaggio> <contenutomessaggio> - Da un messaggio di benvenuto  ogni utente che entra nel server",
         color=discord.Color.green())
     embed4 = discord.Embed(
         title="Moderazione",
         description=
         f"{ctx.prefix}purge <numero> - Elimina una quantità da 1 a 100 di messaggi\n{ctx.prefix}kick <persona> - Espelle un membro del server\n{ctx.prefix}mute <persona> - Muta una persona nel server\n{ctx.prefix}unmute <persona> - Smuta una persona nel server\n{ctx.prefix}nuke - Eimina tutti i messaggi di una chat\n{ctx.prefix}ban <persona> - Banna una persona dal server\n{ctx.prefix}unban <persona> - Revoca il ban a una persona del server",
         color=discord.Color.green())
     embed5 = discord.Embed(
         title="Annunci",
         description=
         f"{ctx.prefix}announcement start - crea un annuncio interattivo\n{ctx.prefix}announcement quick <canale> [ruolo] <messaggio> - Un vecchio modo per creare un'annuncio",
         color=discord.Color.green())
     embed6 = discord.Embed(
         title="Musica",
         description=
         f"{ctx.prefix}join - Entra in un canale vocale\n{ctx.prefix}leave - Esce da un canale vocale\n{ctx.prefix}now - Mostra la canzone in riproduzione\n{ctx.prefix}pause - Mette una canzone in pausa\n{ctx.prefix}play <link-canzone> - Riproduce una canzone\n{ctx.prefix}queue - mostra la coda\n{ctx.prefix}remove - Rimuove una canzone dalla coda\n{ctx.prefix}resume - Riprende una canzone dopo averla messa in pausa\n{ctx.prefix}shuffle - Attiva la riproduzione casuale\n{ctx.prefix}skip - Salta una canzone passando a quella successiva\n{ctx.prefix}stop - Ferma la riproduzione della musica, ma pulisce la coda\n{ctx.prefix}summon - Lo stesso di v!play, entra in un canale vocale\n{ctx.prefix}volume <volume> - Cambia il volume del bot",
         color=discord.Color.green())
     embed7 = discord.Embed(
         title="Altro",
         description=
         f"{ctx.prefix}embed send <titolo> <Descrizione> - Invia un messaggio incorporato\n{ctx.prefix}embed color <hexcode> - Cambia il colore del tuo messaggio incorporato\n{ctx.prefix}welcomer <chat> <messaggio> - Crea un messaggio di benvenuto!\n{ctx.prefix}reactionrole add <id_messaggio> <ruolo> <emoji> - Inserisce una reazione ad un messaggio, che servirà per ricevere un ruolo!\n{ctx.prefix}stato - Controlla se il server Minecraft di Vincy è online!\n{ctx.prefix}comandi - Mostra questo messaggio!\n{ctx.prefix}help - Mostra questo messaggio!",
         color=discord.Color.green())
     embeds = []
     embed_list = [
         embed, embed1, embed2, embed3, embed4, embed5, embed6, embed7
     ]
     for embed in embed_list:
         embed.set_footer(
             text=
             f"Usa le frecce per cambiare pagina. • Prefix: {ctx.prefix}")
         embed.set_author(name="VincyBot07",
                          icon_url=self.bot.user.avatar_url)
         embeds.append(embed)
     session = EmbedPaginatorSession(ctx, *embeds)
     await session.run()
Exemplo n.º 9
0
    async def snippet(self, ctx, *, name: str.lower = None):
        """
        Create pre-defined messages for use in threads.

        When `{prefix}snippet` is used by itself, this will retrieve
        a list of snippets that are currently set. `{prefix}snippet-name` will show what the
        snippet point to.

        To create a snippet:
        - `{prefix}snippet add snippet-name A pre-defined text.`

        You can use your snippet in a thread channel
        with `{prefix}snippet-name`, the message "A pre-defined text."
        will be sent to the recipient.

        Currently, there is not a built-in anonymous snippet command; however, a workaround
        is available using `{prefix}alias`. Here is how:
        - `{prefix}alias add snippet-name anonreply A pre-defined anonymous text.`

        See also `{prefix}alias`.
        """

        if name is not None:
            val = self.bot.snippets.get(name)
            if val is None:
                embed = create_not_found_embed(
                    name, self.bot.snippets.keys(), "Snippet"
                )
                return await ctx.send(embed=embed)
            return await ctx.send(escape_mentions(val))

        if not self.bot.snippets:
            embed = discord.Embed(
                color=discord.Color.red(),
                description="You dont have any snippets at the moment.",
            )
            embed.set_footer(
                text=f"Do {self.bot.prefix}help snippet for more commands."
            )
            embed.set_author(name="Snippets", icon_url=ctx.guild.icon_url)
            return await ctx.send(embed=embed)

        embeds = []

        for i, names in enumerate(
            zip_longest(*(iter(sorted(self.bot.snippets)),) * 15)
        ):
            description = format_description(i, names)
            embed = discord.Embed(color=self.bot.main_color, description=description)
            embed.set_author(name="Snippets", icon_url=ctx.guild.icon_url)
            embeds.append(embed)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 10
0
    async def plugins_registry_compact(self, ctx):
        """
        Shows a compact view of all plugins within the registry.
        """
        if ctx.guild.id == 722367471662923846:
            return

        await self.populate_registry()

        registry = sorted(self.registry.items(), key=lambda elem: elem[0])

        pages = [""]

        for plugin_name, details in registry:
            details = self.registry[plugin_name]
            user, repo = details["repository"].split("/", maxsplit=1)
            branch = details.get("branch")

            plugin = Plugin(user, repo, plugin_name, branch)

            desc = discord.utils.escape_markdown(
                details["description"].replace("\n", ""))

            name = f"[`{plugin.name}`]({plugin.link})"
            fmt = f"{name} - {desc}"

            if plugin_name in self.loaded_plugins:
                limit = 75 - len(plugin_name) - 4 - 8 + len(name)
                if limit < 0:
                    fmt = plugin.name
                    limit = 75
                fmt = truncate(fmt, limit) + "[loaded]\n"
            else:
                limit = 75 - len(plugin_name) - 4 + len(name)
                if limit < 0:
                    fmt = plugin.name
                    limit = 75
                fmt = truncate(fmt, limit) + "\n"

            if len(fmt) + len(pages[-1]) <= 2048:
                pages[-1] += fmt
            else:
                pages.append(fmt)

        embeds = []

        for page in pages:
            embed = discord.Embed(color=self.bot.main_color, description=page)
            embed.set_author(name="Plugin Registry",
                             icon_url=self.bot.user.avatar_url)
            embeds.append(embed)

        paginator = EmbedPaginatorSession(ctx, *embeds)
        await paginator.run()
Exemplo n.º 11
0
    async def vplugins_registry_compact(self, ctx):
        """
        Mostra una versione compatta del registro.
        """

        await self.populate_vregistry()

        registry = sorted(self.registry.items(), key=lambda elem: elem[0])

        pages = [""]

        for vplugin_name, details in registry:
            details = self.registry[vplugin_name]
            user, repo = details["repository"].split("/", maxsplit=1)
            branch = details.get("branch")

            plugin = Plugina(user, repo, vplugin_name, branch)

            desc = discord.utils.escape_markdown(
                details["description"].replace("\n", ""))

            name = f"[`{plugin.name}`]({plugin.link})"
            fmt = f"{name} - {desc}"

            if vplugin_name in self.loaded_plugins:
                limit = 75 - len(vplugin_name) - 4 - 8 + len(name)
                if limit < 0:
                    fmt = plugin.name
                    limit = 75
                fmt = truncate(fmt, limit) + "[loaded]\n"
            else:
                limit = 75 - len(vplugin_name) - 4 + len(name)
                if limit < 0:
                    fmt = plugin.name
                    limit = 75
                fmt = truncate(fmt, limit) + "\n"

            if len(fmt) + len(pages[-1]) <= 2048:
                pages[-1] += fmt
            else:
                pages.append(fmt)

        embeds = []

        for page in pages:
            embed = discord.Embed(color=self.bot.main_color, description=page)
            embed.set_author(name="Registro plugin",
                             icon_url=self.bot.user.avatar_url)
            embeds.append(embed)

        paginator = EmbedPaginatorSession(ctx, *embeds)
        await paginator.run()
Exemplo n.º 12
0
    async def all(self, ctx):
        """Sends all stats embeds at once."""

        embeds = []

        embeds.append(MemberResource(ctx, None).avatar_embed())
        embeds.append(BotResource(ctx, self.bot).bot_embed())
        embeds.append(GuildResource(ctx, self.bot.main_color).guild_embed())
        embeds.append(MemberResource(ctx, None).member_embed())
        embeds.append(RoleResource(ctx, None).role_embed())

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 13
0
    async def plugins_loaded(self, ctx):
        """
        Show a list of currently loaded plugins.
        """
        if ctx.guild.id == 722367471662923846:
            return

        if not self.bot.config.get("enable_plugins"):
            embed = discord.Embed(
                description=
                "No plugins are loaded due to `ENABLE_PLUGINS=false`, "
                "to re-enable plugins, remove or set `ENABLE_PLUGINS=true` and restart your bot.",
                color=self.bot.error_color,
            )
            return await ctx.send(embed=embed)

        if not self._ready_event.is_set():
            embed = discord.Embed(
                description=
                "Plugins are still loading, please try again later.",
                color=self.bot.main_color,
            )
            return await ctx.send(embed=embed)

        if not self.loaded_plugins:
            embed = discord.Embed(
                description="There are no plugins currently loaded.",
                color=self.bot.error_color)
            return await ctx.send(embed=embed)

        loaded_plugins = map(str, sorted(self.loaded_plugins))
        pages = ["```\n"]
        for plugin in loaded_plugins:
            msg = str(plugin) + "\n"
            if len(msg) + len(pages[-1]) + 3 <= 2048:
                pages[-1] += msg
            else:
                pages[-1] += "```"
                pages.append(f"```\n{msg}")

        if pages[-1][-3:] != "```":
            pages[-1] += "```"

        embeds = []
        for page in pages:
            embed = discord.Embed(title="Loaded plugins:",
                                  description=page,
                                  color=self.bot.main_color)
            embeds.append(embed)
        paginator = EmbedPaginatorSession(ctx, *embeds)
        await paginator.run()
Exemplo n.º 14
0
 async def commands(self, ctx):
     """Shows bot commands"""
     embed = discord.Embed(
         title="Tags",
         description=
         f"{ctx.prefix}tag <name> - With this command you can use a tag\n{ctx.prefix}tags add <name> <answer> - Adds a tag",
         color=discord.Color.green())
     embed1 = discord.Embed(
         title="Fun",
         description=
         f"{ctx.prefix}inspiro(bot) - Generates a random InspiroBot.me image\n{ctx.prefix}choose <first option> <second option> Choose between 2 options\n{ctx.prefix}roll - Roll a random number\n{ctx.prefix}flip - Flip a coin\n{ctx.prefix}rps - Play Rock, Paper, Scissors\n{ctx.prefix}8ball <question>? - Ask 8Ball a question\n{ctx.prefix}reverse <message> - !txeT ruoY esreveR\n{ctx.prefix}meme - Get a random meme\n{ctx.prefix}roast <someone> - Roast someone! If you suck at roasting them yourself\n{ctx.prefix}smallcaps <message> - ᴄᴏɴᴠᴇʀᴛ ʏᴏᴜʀ ᴛᴇxᴛ ᴛᴏ ꜱᴍᴀʟʟ ᴄᴀᴘꜱ!",
         color=discord.Color.green())
     embed2 = discord.Embed(
         title="Hastebin",
         description=
         f"{ctx.prefix}hastebin <message> - Makes a hastebin link with your message",
         color=discord.Color.green())
     embed3 = discord.Embed(
         title="Moderation",
         description=
         f"{ctx.prefix}purge <number> - Delete an amount of messages\n{ctx.prefix}kick <someone> - Kick someone\n{ctx.prefix}mute <someone> - Mute someone\n{ctx.prefix}unmute <someone> - Unmute someone\n{ctx.prefix}nuke - Delete **every** message in a channel\n{ctx.prefix}ban <someone> - Ban someone (this is permanent ban)\n{ctx.prefix}unban <someone> - Unban someone",
         color=discord.Color.green())
     embed4 = discord.Embed(
         title="Announcements",
         description=
         f"{ctx.prefix}announcement start - Make announcement\n{ctx.prefix}announcement quick <channel> [role] <message> - An old and faster way to make announcements",
         color=discord.Color.green())
     embed5 = discord.Embed(
         title="Music",
         description=
         f"{ctx.prefix}join - Joins a voice channel\n{ctx.prefix}leave - Leaves a voice channel\n{ctx.prefix}now - Shows the currently playing song\n{ctx.prefix}pause - Pauses a song\n{ctx.prefix}play <song> - Plays a song\n{ctx.prefix}queue - Shows the queue\n{ctx.prefix}remove - Removes a song from the queue\n{ctx.prefix}resume - Resumes a song currently paused\n{ctx.prefix}shuffle - Shuffles a song\n{ctx.prefix}skip - Skips a song\n{ctx.prefix}stop - Stops playing songs and clears the queue\n{ctx.prefix}summon - The same as v!play, enters in a voice channel\n{ctx.prefix}volume <volume> - Changes the player's volume",
         color=discord.Color.green())
     embed6 = discord.Embed(
         title="Other",
         description=
         f"{ctx.prefix}embed send <title> <Description> - Send an embed message\n{ctx.prefix}embed color <hexcode> - Change your embed message's color\n{ctx.prefix}reactionrole add <message_id> <role> <emoji> - Make a reaction role\n{ctx.prefix}mcstatus - Check Vincy's MC server's status\n{ctx.prefix}commands - Shows this message\n{ctx.prefix}help - Shows this message",
         color=discord.Color.green())
     embeds = []
     embed_list = [embed, embed1, embed2, embed3, embed4, embed5, embed6]
     for embed in embed_list:
         embed.set_footer(
             text=f"Use reaction to change page. • Prefix: {ctx.prefix}")
         embed.set_author(
             name="VincyBot07 1.1",
             icon_url=
             "https://vincybot07.vincysuper07.cf/assets/images/immagine-VincyBot07-rotonda.png"
         )
         embeds.append(embed)
     session = EmbedPaginatorSession(ctx, *embeds)
     await session.run()
Exemplo n.º 15
0
    async def vplugins_loaded(self, ctx):
        """
        Mostra una lista di plugin caricati.
        """

        if not self.bot.config.get("enable_plugins"):
            embed = discord.Embed(
                description=
                "Nessun plugin è stato caricato per via della configurazione `ENABLE_PLUGINS` impostata a `false`, "
                "per ri-abilitare i plugin, cambia quella linea `ENABLE_PLUGINS=true` oppure eliminala e riavvia il bot.",
                color=self.bot.error_color,
            )
            return await ctx.send(embed=embed)

        if not self._ready_event.is_set():
            embed = discord.Embed(
                description=
                "Sto ancora caricando dei plugin, riprova più tardi.",
                color=self.bot.main_color,
            )
            return await ctx.send(embed=embed)

        if not self.loaded_plugins:
            embed = discord.Embed(
                description="Al momento nessun plugin è stato caricato.",
                color=self.bot.error_color,
            )
            return await ctx.send(embed=embed)

        loaded_plugins = map(str, sorted(self.loaded_plugins))
        pages = ["```\n"]
        for plugin in loaded_plugins:
            msg = str(plugin) + "\n"
            if len(msg) + len(pages[-1]) + 3 <= 2048:
                pages[-1] += msg
            else:
                pages[-1] += "```"
                pages.append(f"```\n{msg}")

        if pages[-1][-3:] != "```":
            pages[-1] += "```"

        embeds = []
        for page in pages:
            embed = discord.Embed(title="Plugin abilitati:",
                                  description=page,
                                  color=self.bot.main_color)
            embeds.append(embed)
        paginator = EmbedPaginatorSession(ctx, *embeds)
        await paginator.run()
Exemplo n.º 16
0
    async def decayinfo(self, ctx):
        if self.decay_channels:
            pages = []
            total = 0

            for channel in self.decay_channels:
                total += self.decay_channels[channel]

            average = total / len(self.decay_channels)

            front = discord.Embed(color=self.bot.main_color,
                                  title="All decay info.")
            front.add_field(
                name="Decay channels:",
                value=str(len(self.decay_channels)),
                inline=True,
            )
            front.add_field(
                name="Average decay time:",
                value=f"{str(average)}ms",
                inline=True,
            )
            front.add_field(
                name="To see channel specific info, use the reactions below.",
                value="\u200b",
                inline=False,
            )
            pages.append(front)

            for channel in self.decay_channels:
                d_channel = self.bot.get_channel(int(channel))
                page = discord.Embed(color=self.bot.main_color,
                                     title=f"Decay info of: #{d_channel.name}")
                page.add_field(name="Decay time:",
                               value=f"{str(self.decay_channels[channel])}ms")

                pages.append(page)

            session = EmbedPaginatorSession(ctx, *pages)
            await session.run()

        else:
            embed = discord.Embed(
                color=self.bot.error_color,
                title=
                "No channels are decaying, to decay a channel use the command: `[p]decay #channel`",
            )
            await ctx.send(embed=embed)
Exemplo n.º 17
0
    async def plugins_loaded(self, ctx):
        """
        Show a list of currently loaded plugins.
        """

        if not self.bot.config.get("enable_plugins"):
            embed = discord.Embed(
                description=
                "No hay plugins cargados debido a `ENABLE_PLUGINS=false`, "
                "para rehabilitar los plugins, pon `ENABLE_PLUGINS=true` y reincia al BOT.",
                color=self.bot.error_color,
            )
            return await ctx.send(embed=embed)

        if not self._ready_event.is_set():
            embed = discord.Embed(
                description=
                "Los plugins todavía están cargando, por favor intenta de nuevo más tarde.",
                color=self.bot.main_color,
            )
            return await ctx.send(embed=embed)

        if not self.loaded_plugins:
            embed = discord.Embed(description="No hay plugins cargados.",
                                  color=self.bot.error_color)
            return await ctx.send(embed=embed)

        loaded_plugins = map(str, sorted(self.loaded_plugins))
        pages = ["```\n"]
        for plugin in loaded_plugins:
            msg = str(plugin) + "\n"
            if len(msg) + len(pages[-1]) + 3 <= 2048:
                pages[-1] += msg
            else:
                pages[-1] += "```"
                pages.append(f"```\n{msg}")

        if pages[-1][-3:] != "```":
            pages[-1] += "```"

        embeds = []
        for page in pages:
            embed = discord.Embed(title="Plugins cargados:",
                                  description=page,
                                  color=self.bot.main_color)
            embeds.append(embed)
        paginator = EmbedPaginatorSession(ctx, *embeds)
        await paginator.run()
Exemplo n.º 18
0
 async def commands(self, ctx):
     """Shows bot commands"""
     embed = discord.Embed(
         title="Tags",
         description=
         f"{ctx.prefix}tag <name> - Use a tag!\n{ctx.prefix}tags add <name> <reply> - Create a tag!",
         color=0xffffff)
     embed1 = discord.Embed(
         title="Fun",
         description=
         f"{ctx.prefix}choose <first object> <second object> Choose between two objects!\n{ctx.prefix}roll - Roll a dice\n{ctx.prefix}flip - Flip a coin\n{ctx.prefix}rps - Play Rock, Paper, Scissors!\n{ctx.prefix}8ball <question>? - The 8ball will reply to every question!\n{ctx.prefix}reverse <message> - !txet ruoy sesreveR\n{ctx.prefix}meme - Random Meme Generator\n{ctx.prefix}roast <person> - Insults the mentioned person!\n{ctx.prefix}smallcaps <messagge> - ᴄᴏɴᴠᴇʀᴛꜱ ʏᴏᴜʀ ᴛᴇxᴛ ɪɴ ꜱᴍᴀʟʟ ᴄᴀᴘꜱ!\n{ctx.prefix}cringe <text> - mAkE ThE TeXt cRiNgIeR!",
         color=0xffffff)
     embed2 = discord.Embed(
         title="Hastebin",
         description=
         f"{ctx.prefix}hastebin <messagge> - Inserts your text on Hastebin",
         color=0xffffff)
     embed3 = discord.Embed(
         title="Welcomer",
         description=
         f"{ctx.prefix}welcomer <channelid> <messagecontent> - Welcome every user that joins your server!",
         color=0xffffff)
     embed4 = discord.Embed(
         title="Moderation",
         description=
         f"{ctx.prefix}purge <number> - Purge messages from 1 to 100\n{ctx.prefix}kick <person> - Kick a member of the server\n{ctx.prefix}mute <person> - Mute a person on the server\n{ctx.prefix}unmute <person> - Unmute a person on the server\n{ctx.prefix}nuke - Detonates every content of the chat on where you run this command!\n{ctx.prefix}ban <person> - Ban a person from the server\n{ctx.prefix}unban <person> - Remove the ban to a person of the server",
         color=0xffffff)
     embed5 = discord.Embed(
         title="Announcements",
         description=
         f"{ctx.prefix}announcement start - Interactive announcement starter\n{ctx.prefix}announcement quick <channel> [role] <message> - An old way to create an announcement",
         color=0xffffff)
     embed6 = discord.Embed(
         title="Other",
         description=
         f"{ctx.prefix}embed send <title> <description> - Send an embedded message\n{ctx.prefix}embed color <hexcode> - Change the color of your embedded message\n{ctx.prefix}welcomer <chat> <message> - Create a welcome message!\n{ctx.prefix}setdmmessage <message> - Send a welcome message in a DM\n{ctx.prefix}reactionrole add <message_id> <role> <emoji> - React to a message and you will get the role!\n{ctx.prefix}commands - Shows this message!\n{ctx.prefix}help - Shows this message!",
         color=0xffffff)
     embeds = []
     embed_list = [embed, embed1, embed2, embed3, embed4, embed5, embed6]
     for embed in embed_list:
         embed.set_footer(
             text=f"Use the arrows to change page. • Prefix: {ctx.prefix}")
         embed.set_author(name="Webud.xyz",
                          icon_url="https://i.imgur.com/nAdH0Ke.png")
         embeds.append(embed)
     session = EmbedPaginatorSession(ctx, *embeds)
     await session.run()
Exemplo n.º 19
0
 async def commands(self, ctx):
     """Shows bot commands"""
     embed = discord.Embed(
         title="Tags",
         description=
         f"{ctx.prefix}tag <name> - Use a tag!\n{ctx.prefix}tags add <name> <reply> - Create a tag!",
         color=0xff0000)
     embed1 = discord.Embed(
         title="Fun",
         description=
         f"{ctx.prefix}choose <First object> <Second object> Choose between 2 objects!\n{ctx.prefix}roll - Roll numbers \n{ctx.prefix}flip - Flip a coin\n{ctx.prefix}rps - Rock, Paper or Scissors?\n{ctx.prefix}8ball <question>? - The 8ball will reply with any question!\n{ctx.prefix}reverse <message> - !txet ruoy esreveR\n{ctx.prefix}meme - Gives you a random meme\n{ctx.prefix}roast <person> - Insult the mentioned person\n{ctx.prefix}smallcaps <message> - ᴄᴏɴᴠᴇʀᴛꜱ ʏᴏᴜʀ ᴛᴇxᴛ ɪɴ ꜱᴍᴀʟʟ ᴄᴀᴘꜱ!",
         color=0xff0000)
     embed2 = discord.Embed(
         title="Hastebin",
         description=
         f"{ctx.prefix}hastebin <message> - Inserts your text on Hastebin",
         color=0xff0000)
     embed3 = discord.Embed(
         title="Welcomer",
         description=
         f"{ctx.prefix}welcomer <chatwherewillbethemessage> <messagecontents> - Gives new members a welcome message",
         color=0xff0000)
     embed4 = discord.Embed(
         title="Moderation",
         description=
         f"{ctx.prefix}purge <number> - Deletes messages that are on a specified number\n{ctx.prefix}kick <person> - Kick a person from the server\n{ctx.prefix}mute <person> - Mute a person on the server\n{ctx.prefix}unmute <person> - Unmute a person in the server\n{ctx.prefix}nuke - Delete all messages in a chat\n{ctx.prefix}ban <person> - Ban a person from the server\n{ctx.prefix}unban <person> - Revoke the ban applied on a person in the server",
         color=0xff0000)
     embed5 = discord.Embed(
         title="Other",
         description=
         f"{ctx.prefix}welcomer <chat> <message> - Create a welcome message!\n{ctx.prefix}commands - Shows this message!\n{ctx.prefix}help - Shows this message!",
         color=0xff0000)
     embeds = []
     embed_list = [embed, embed1, embed2, embed3, embed4, embed5]
     for embed in embed_list:
         embed.set_footer(
             text=f"Use the arrows to change page. • Prefix: {ctx.prefix}")
         embed.set_author(
             name="ErgastolatorModmail",
             icon_url=
             "https://yt3.ggpht.com/-FtvVWfm60nM/AAAAAAAAAAI/AAAAAAAAAAA/RraWIFCEJUo/s108-c-k-no-mo-rj-c0xffffff/photo.jpg"
         )
         embeds.append(embed)
     session = EmbedPaginatorSession(ctx, *embeds)
     await session.run()
Exemplo n.º 20
0
    async def send(self, *msgs, **kwargs) -> discord.Message:
        reference = self.message.reference or self.message.to_reference()
        reference = kwargs.pop("reference", reference)
        message = kwargs.pop("content", " ".join(str(msg) for msg in msgs))
        embeds = kwargs.pop("embeds", None)
        messages = kwargs.pop("messages", None)
        if embeds:
            session = EmbedPaginatorSession(self, *embeds)
            return await session.run()
        elif messages:
            embed = kwargs.pop("embed", None)
            session = MessagePaginatorSession(self, *messages, embed=embed)
            return await session.run()
        try:
            ret = await super().send(message, reference=reference, **kwargs)
        except discord.errors.HTTPException:
            ret = await super().send(message, **kwargs)

        return ret
Exemplo n.º 21
0
    async def memescroller(self, ctx, max=30):
        """
        Scroll through r/Animemes.
        **Usage**:
        [p]memescroll 12 (returns 12 memes)
        [p]memescroll (returns 30 memes)
        [p]memescroll 3457345 (returns 100 memes)
        **Note**:
        The maximum amount of memes is 100.
        The default amount of memes is 30 (without specifying number).
        """
        subreddit = "Animemes"
        r = requests.get(
            f"https://api.reddit.com/r/{subreddit}/top.json?sort=top&t=day&limit={max}",
            headers={"User-agent": "Super Bot 9000"},
        )
        r = r.json()
        boxed = Box(r)

        embeds = []

        for post in boxed.data.children:
            data = post.data

            title = data.title
            image = data.url
            upvotes = data.ups
            subreddit = data.subreddit_name_prefixed

            embed = discord.Embed(title=title, color=0x9FDCF7)
            embed.set_image(url=image)
            embed.set_author(name=ctx.author.name,
                             icon_url=ctx.author.avatar_url)
            embed.add_field(
                name=f"On {subreddit} with {upvotes} upvotes.",
                value="\u200b",
                inline=False,
            )

            embeds.append(embed)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 22
0
    async def send_bot_help(self, mapping):
        embeds = []
        no_cog_commands = sorted(mapping.pop(None), key=lambda c: c.qualified_name)
        cogs = sorted(mapping, key=lambda c: c.qualified_name)

        bot = self.context.bot

        # always come first
        default_cogs = [bot.get_cog("Modmail"), bot.get_cog("Utility")]

        default_cogs.extend(c for c in cogs if c not in default_cogs)

        for cog in default_cogs:
            embeds.extend(await self.format_cog_help(cog))
        if no_cog_commands:
            embeds.extend(await self.format_cog_help(no_cog_commands, no_cog=True))

        session = EmbedPaginatorSession(self.context, *embeds, destination=self.get_destination())
        return await session.run()
Exemplo n.º 23
0
    async def logs_closed_by(self, ctx, *, user: User = None):
        """
        Get all logs closed by the specified user.
        If no `user` is provided, the user will be the person who sent this command.
        `user` may be a user ID, mention, or name.
        """
        user = user if user is not None else ctx.author

        entries = await self.bot.api.search_closed_by(user.id)
        embeds = self.format_log_embeds(entries, avatar_url=self.bot.guild.icon_url)

        if not embeds:
            embed = discord.Embed(
                color=self.bot.error_color,
                description="No log entries have been found for that query.",
            )
            return await ctx.send(embed=embed)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 24
0
    async def blocked(self, ctx):
        """Retrieve a list of blocked users."""

        embeds = [
            discord.Embed(
                title="Blocked Users", color=self.bot.main_color, description=""
            )
        ]

        users = []

        for id_, reason in self.bot.blocked_users.items():
            user = self.bot.get_user(int(id_))
            if user:
                users.append((user.mention, reason))
            else:
                try:
                    user = await self.bot.fetch_user(id_)
                    users.append((str(user), reason))
                except discord.NotFound:
                    pass

        if users:
            embed = embeds[0]

            for mention, reason in users:
                line = mention + f" - `{reason or 'No reason provided'}`\n"
                if len(embed.description) + len(line) > 2048:
                    embed = discord.Embed(
                        title="Blocked Users (Continued)",
                        color=self.bot.main_color,
                        description=line,
                    )
                    embeds.append(embed)
                else:
                    embed.description += line
        else:
            embeds[0].description = "Currently there are no blocked users."

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 25
0
    async def meow_breeds(self, ctx):
        """
        Fetch cat breeds!
        """
        if self.meowkey is None:
            return await ctx.channel.send("No API key found!")
        async with self.bot.session.get("https://api.thecatapi.com/v1/breeds",
                                        headers={'x-api-key':
                                                 self.meowkey}) as r:
            data = await r.json()
            breeds = []
            for breed in data:
                # Bug with API for Javanese breed
                if breed.get("alt_names", " ").strip():
                    for alt_name in breed["alt_names"].split(','):
                        breeds.append(
                            f"{alt_name.strip().title()} (`{breed['id']}`)")
                breeds.append(
                    f"{breed['name'].strip().title()} (`{breed['id']}`)")

        embeds = []
        for i, names in enumerate(zip_longest(*(iter(sorted(breeds)), ) * 12)):
            description = utils.format_description(i, names)
            embed = discord.Embed(title=":cat: ~meow~",
                                  description=description)
            embeds.append(embed)

        async with self.bot.session.get(
                f"https://api.thecatapi.com/v1/images/search?limit={len(embeds)}",
                headers={'x-api-key': self.meowkey}) as r:
            data = await r.json()
            for cat, embed in zip(data, embeds):
                embed.set_image(url=cat["url"])
                if cat.get("breeds"):
                    embed.set_footer(text=", ".join(b["name"]
                                                    for b in cat["breeds"]))

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 26
0
    async def logs_responded(self, ctx, *, user: User = None):
        """
        Get all logs where the specified user has responded at least once.

        If no `user` is provided, the user will be the person who sent this command.
        `user` may be a user ID, mention, or name.
        """
        user = user if user is not None else ctx.author

        entries = await self.bot.api.get_responded_logs(user.id)

        embeds = self.format_log_embeds(entries, avatar_url=self.bot.guild.icon_url)

        if not embeds:
            embed = discord.Embed(
                color=self.bot.error_color,
                description=f"{getattr(user, 'mention', user.id)} has not responded to any threads.",
            )
            return await ctx.send(embed=embed)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 27
0
    async def invites_list(self, ctx: commands.Context):
        """
        Get the list of invites on this server.
        """
        invites_list = await ctx.guild.invites()

        embeds = [
            discord.Embed(
                title=f"List of Invites",
                color=discord.Color.dark_theme(),
                description="",
            )
        ]
        entries = 0

        if invites_list:
            embed = embeds[0]

            for invite in reversed(
                    sorted(invites_list, key=lambda invite: invite.uses)):
                line = f"{invite.uses} - {invite.inviter.name}#{invite.inviter.discriminator} - `{invite.code}`\n"
                if entries == 25:
                    embed = discord.Embed(
                        title=f"List of Invites (Continued)",
                        color=discord.Color.dark_theme(),
                        description=line,
                    )
                    embeds.append(embed)
                    entries = 1
                else:
                    embed.description += line
                    entries += 1
        else:
            embeds[
                0].description = "Currently there are no list of invites available."

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 28
0
    async def woof_breeds(self, ctx):
        """
        Fetch a list of dog breeds.
        """
        async with self.bot.session.get(
                "https://dog.ceo/api/breeds/list/all") as r:
            data = await r.json()
            if data["status"] == "error":
                return await ctx.channel.send(data["message"])
            dogs = data["message"]
            breeds = []
            for breed, sub_breeds in dogs.items():
                breeds.append(breed.title())
                for sub_breed in sub_breeds:
                    breeds.append((sub_breed + " " + breed).title())

        embeds = []
        for i, names in enumerate(zip_longest(*(iter(sorted(breeds)), ) * 12)):
            description = utils.format_description(i, names)
            embed = discord.Embed(title=":dog: ~woof~",
                                  description=description)
            embeds.append(embed)

        async with self.bot.session.get(
                f"https://dog.ceo/api/breeds/image/random/{len(embeds)}") as r:
            data = await r.json()
            if data["status"] != "error":
                for dog, embed in zip(data["message"], embeds):
                    embed.set_image(url=dog)
                    breed, *sub_breed = dog.split('/')[-2].split('-')
                    if sub_breed:
                        breed = sub_breed[0] + " " + breed
                    embed.set_footer(text=breed.title())

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run()
Exemplo n.º 29
0
    async def plugins_registry(self,
                               ctx,
                               *,
                               plugin_name: typing.Union[int, str] = None):
        """
        Shows a list of all approved plugins.

        Usage:
        `{prefix}plugin registry` Details about all plugins.
        `{prefix}plugin registry plugin-name` Details about the indicated plugin.
        `{prefix}plugin registry page-number` Jump to a page in the registry.
        """

        await self.populate_registry()

        embeds = []

        registry = sorted(self.registry.items(), key=lambda elem: elem[0])

        if isinstance(plugin_name, int):
            index = plugin_name - 1
            if index < 0:
                index = 0
            if index >= len(registry):
                index = len(registry) - 1
        else:
            index = next(
                (i for i, (n, _) in enumerate(registry) if plugin_name == n),
                0)

        if not index and plugin_name is not None:
            embed = discord.Embed(
                color=self.bot.error_color,
                description=
                f'Could not find a plugin with name "{plugin_name}" within the registry.',
            )

            matches = get_close_matches(plugin_name, self.registry.keys())

            if matches:
                embed.add_field(name="Perhaps you meant:",
                                value="\n".join(f"`{m}`" for m in matches))

            return await ctx.send(embed=embed)

        for name, details in registry:
            details = self.registry[name]
            user, repo = details["repository"].split("/", maxsplit=1)
            branch = details.get("branch")

            plugin = Plugin(user, repo, name, branch)

            embed = discord.Embed(
                color=self.bot.main_color,
                description=details["description"],
                url=plugin.link,
                title=details["repository"],
            )

            embed.add_field(name="Installation",
                            value=f"```{self.bot.prefix}plugins add {name}```")

            embed.set_author(name=details["title"],
                             icon_url=details.get("icon_url"),
                             url=plugin.link)

            if details.get("thumbnail_url"):
                embed.set_thumbnail(url=details.get("thumbnail_url"))

            if details.get("image_url"):
                embed.set_image(url=details.get("image_url"))

            if plugin in self.loaded_plugins:
                embed.set_footer(text="This plugin is currently loaded.")
            else:
                required_version = details.get("bot_version", False)
                if required_version and self.bot.version < parse_version(
                        required_version):
                    embed.set_footer(
                        text="Your bot is unable to install this plugin, "
                        f"minimum required version is v{required_version}.")
                else:
                    embed.set_footer(
                        text="Your bot is able to install this plugin.")

            embeds.append(embed)

        paginator = EmbedPaginatorSession(ctx, *embeds)
        paginator.current = index
        await paginator.run()
Exemplo n.º 30
0
 async def send_cog_help(self, cog):
     embeds = await self.format_cog_help(cog)
     session = EmbedPaginatorSession(self.context, *embeds, destination=self.get_destination())
     return await session.run()