Пример #1
0
    async def embed(self, ctx: commands.Context, **kwargs):
        """
        Send an embed and its fully customizable
        Default mention settings:
            Users:      Enabled
            Roles:      Disabled
            Everyone:   Disabled
        """
        embed = dict_to_embed(kwargs, author=ctx.author)
        allowed_mentions = dict_to_allowed_mentions(kwargs)
        message = process_message_mentions(kwargs.pop("message"))

        if kwargs.pop("webhook"):
            if edit_message := kwargs.pop("edit"):
                edit_message.close()
            username, avatar_url = kwargs.pop("webhook_username"), kwargs.pop(
                "webhook_avatar")
            if kwargs.pop("webhook_auto_author"):
                username, avatar_url = (
                    username or ctx.author.display_name,
                    avatar_url or ctx.author.avatar_url,
                )
            target = kwargs.pop("channel") or ctx.channel
            if name := kwargs.pop("webhook_new_name"):
                wh = await target.create_webhook(name=name)
Пример #2
0
    async def add(self, ctx: commands.Context, **kwargs):
        """Submit your brainfeed for approval and publishing"""
        embed = dict_to_embed(kwargs)
        embed.set_author(name=ctx.author.name,
                         icon_url=str(ctx.author.avatar_url))
        embed.timestamp = datetime.now()
        msg = await ctx.send(embed=embed)
        await msg.add_reaction("\u2705")
        await msg.add_reaction("\u274c")

        def check(r: Reaction, u: Member):
            return (u == ctx.author and r.emoji in ("\u2705", "\u274c")
                    and r.message == msg)

        try:
            r, _ = await self.bot.wait_for("reaction_add",
                                           check=check,
                                           timeout=120)
        except asyncio.TimeoutError:
            return await msg.reply("Timeout!")
        if r.emoji == "\u274c":
            return await ctx.send("Cancelled!")
        await ctx.trigger_typing()
        submission = await self.submission_channel.send(embed=embed)
        metaembed = Embed(
            title="Submission details",
            description=("```"
                         f"User ID: {ctx.author.id}\n"
                         f"User name: {ctx.author}\n"
                         f"Channel ID: {ctx.channel.id}\n"
                         f"Channel name: {ctx.channel}\n"
                         f"Guild ID: {ctx.guild.id}\n"
                         f"Guild name: {ctx.guild}\n"
                         "```"),
        )
        await submission.reply(embed=metaembed)
        await ctx.send(f"Submitted\nSubmission ID: {submission.id}")