How to use the discord.Embed function in discord

To help you get started, we’ve selected a few discord examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Run1e / AceBot / cogs / stats.py View on Github external
top_users = await db.all(query, guild.id)

		query = """
			SELECT COUNT(id), author_id
			FROM log
			WHERE guild_id = $1
			AND date > $2
			GROUP BY author_id
			ORDER BY COUNT DESC
			LIMIT 5
		"""

		top_users_today = await db.all(query, guild.id, now)

		e = discord.Embed(description=f'{uses} total commands issued.')
		e.set_author(name=guild.name, icon_url=guild.icon_url)

		e.add_field(
			name='Top Commands',
			value=self.create_list(all_time),
		)

		e.add_field(
			name="Today's Top Commands",
			value=self.create_list(today),
		)

		e.add_field(
			name='Top Users',
			value=self.create_list(top_users, [f'<@{user}>' for _, user in top_users]),
		)
github lu-ci / apex-sigma-core / sigma / modules / utilities / ids / roleid.py View on Github external
"""
    :param _cmd: The command object referenced in the command.
    :type _cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    embed = True
    if pld.args:
        lookup = ' '.join(pld.args)
        if pld.args[-1].lower() == '--text':
            embed = False
            lookup = ' '.join(pld.args[:-1])
        role = discord.utils.find(lambda x: x.name.lower() == lookup.lower(), pld.msg.guild.roles)
        if role:
            if embed:
                response = discord.Embed(color=0x3B88C3)
                response.add_field(name=f'ℹ {role.name}', value=f'`{role.id}`')
            else:
                response = role.id
        else:
            embed = True
            response = not_found(f'{lookup} not found.')
    else:
        response = error('Nothing inputted.')
    if embed:
        await pld.msg.channel.send(embed=response)
    else:
        await pld.msg.channel.send(response)
github lu-ci / apex-sigma-core / sigma / modules / fun / quotes / famousquote.py View on Github external
if data:
        text = data['quoteText']
        while text.endswith(' '):
            text = text[:-1]
        if 'quoteAuthor' in data:
            author = data['quoteAuthor']
        else:
            author = 'Unknown'
        if not author:
            author = 'Unknown'
        quote_text = f'\"{text}\"'
    else:
        author = 'Sir Winston Churchill'
        quote_text = '"Some people\'s " idea of free speech is that they are free to say'
        quote_text += f' what the like, but if anyone says anything back, that is an outrage."'
    response = discord.Embed(color=0xF9F9F9)
    response.add_field(name=f'📑 A Quote From {author}', value=quote_text)
    await message.channel.send(None, embed=response)
github avrae / avrae / cogs5e / dice.py View on Github external
async def monster_save(self, ctx, monster_name, save_stat, *args):
        """Rolls a save for a monster.
        __Valid Arguments__
        adv/dis
        -b [conditional bonus]
        -phrase [flavor text]
        -title [title] *note: [name] and [cname] will be replaced automatically*
        -thumb [thumbnail URL]
        -dc [dc]
        -rr [iterations]
        -h (hides name and image of monster)"""

        monster: Monster = await select_monster_full(ctx, monster_name)

        embed = discord.Embed()
        embed.colour = random.randint(0, 0xffffff)

        args = await helpers.parse_snippets(args, ctx)
        args = argparse(args)

        if not args.last('h', type_=bool):
            embed.set_thumbnail(url=monster.get_image_url())

        checkutils.run_save(save_stat, monster, args, embed)

        if monster.homebrew:
            embeds.add_homebrew_footer(embed)

        await ctx.send(embed=embed)
        await try_delete(ctx.message)
github strinking / futaba / futaba / cogs / welcome / prune.py View on Github external
pruned_members = await self.prune_member(ctx, days)

        # Check if prune_members is None as if it is there is not member role set
        # If there is no member role set pruning members makes no sense
        if pruned_members is None:
            error_message = (
                "The server has no member role set, so pruning will have no effect"
            )
            embed = discord.Embed(
                description=error_message, colour=discord.Colour.red()
            )
            raise CommandFailed(embed=embed)

        content = f"Pruned {pruned_members} members"
        embed = discord.Embed(description=content, colour=discord.Colour.dark_teal())
        await ctx.send(embed=embed)

        self.journal.send(
            "prune",
            ctx.guild,
            content,
            icon="snip",
            cause=ctx.author,
            members=pruned_members,
        )
github Godavaru / Godavaru / Godavaru Main / cog_info.py View on Github external
async def changelog(self, ctx):
        """Check the most recent changelog for all of the newer features!

        **Usage:** `g_changelog`

        **Permission:** User"""
        changelogChannel = discord.utils.get(discord.utils.get(self.bot.guilds, id=315251940999299072).channels, id=315602734235516928)
        async for m in changelogChannel.history(limit=1):
            changelog = m.clean_content
            desii = m.author
            lastUpdate = m.created_at
        em = discord.Embed(description=changelog, color=ctx.message.author.color)
        em.set_author(icon_url=desii.avatar_url.replace("?size=1024", ""), name="Found the latest changelog from my support guild!")
        em.timestamp = lastUpdate
        await ctx.send(embed=em)
github Cog-Creators / Red-DiscordBot / redbot / cogs / reports / reports.py View on Github external
author = guild.get_member(msg.author.id)
        report = msg.clean_content

        channel_id = await self.config.guild(guild).output_channel()
        channel = guild.get_channel(channel_id)
        if channel is None:
            return None

        files: List[discord.File] = await Tunnel.files_from_attach(msg)

        ticket_number = await self.config.guild(guild).next_ticket()
        await self.config.guild(guild).next_ticket.set(ticket_number + 1)

        if await self.bot.embed_requested(channel, author):
            em = discord.Embed(description=report)
            em.set_author(
                name=_("Report from {author}{maybe_nick}").format(
                    author=author, maybe_nick=(f" ({author.nick})" if author.nick else "")
                ),
                icon_url=author.avatar_url,
            )
            em.set_footer(text=_("Report #{}").format(ticket_number))
            send_content = None
        else:
            em = None
            send_content = _("Report from {author.mention} (Ticket #{number})").format(
                author=author, number=ticket_number
            )
            send_content += "\n" + report

        try:
github Rapptz / RoboDanny / cogs / splatoon.py View on Github external
def prepare_embed(self, salmon, page, *, first=False):
        self.embed = e = discord.Embed(colour=0xFF7500, title='Salmon Run')

        if salmon.image:
            e.set_image(url=salmon.image)

        now = datetime.datetime.utcnow()
        if now <= salmon.start_time:
            e.set_footer(text='Starts').timestamp = salmon.start_time
            e.description = f'Starts in {time.human_timedelta(salmon.start_time)}'
        elif now <= salmon.end_time:
            e.set_footer(text='Ends').timestamp = salmon.end_time
            e.description = f'Ends in {time.human_timedelta(salmon.end_time)}'

        e.add_field(name='Weapons', value='\n'.join(salmon.weapons) or 'Unknown')
        e.add_field(name='Map', value=salmon.stage or 'Unknown')

        if self.maximum_pages > 1:
github franc-ist / youtube / modules / YouTube.py View on Github external
value=vidurl, inline=False)
                    data.set_image(
                        url="https://i.ytimg.com/vi/{}/hqdefault.jpg".format(vidid))
                    data.set_footer(
                        text="Made with \U00002665 by Francis#6565. Support server: https://discord.gg/yp8WpMh")
                    try:
                        await ctx.send(embed=data)
                        statsd.increment('bot.commands.run', 1)
                    except discord.HTTPException:
                        statsd.increment('bot.commands.errored', 1)
                        logger.exception("Missing embed links perms")
                        await ctx.send("Looks like the bot doesn't have embed links perms... It kinda needs these, so I'd suggest adding them!")
        except Exception as e:
            logger.exception(e)
            statsd.increment('bot.commands.errored', 1)
            data = discord.Embed(title="__***Error in video search!***__",
                                 description="No data for video ID!", colour=discord.Colour(value=11735575))
            data.add_field(name="Whoops!", value="Looks like the API returned a video, but there is no associated data with it!\nThis could be due to the video being unavailable anymore, or it is country blocked!", inline=False)
            data.add_field(name="What can I do now?",
                           value="Not much really. *__Please don't re-search the video__*, as this adds unnecessary strain on the bot, and you'll get the same result.", inline=False)
            data.set_footer(text="Made with \U00002665 by Francis#6565")
            try:
                await ctx.send(embed=data)
            except discord.HTTPException:
                logger.exception("Missing embed links perms")
                await ctx.send("Looks like the bot doesn't have embed links perms... It kinda needs these, so I'd suggest adding them!")
github nguuuquaaa / Belphegor / belphegor / game.py View on Github external
Each user can only play one board game across all servers at a time.
            Bots and those who are already playing are excluded.
            If command is invoked without argument then the rules is displayed instead.
        '''
        if members:
            all_members = set([ctx.author])
            all_members.update((m for m in members if not m.bot))
            new_game = await board_game.CaNgua.new_game(ctx, all_members)
            self.games[new_game.game_id] = new_game
            await ctx.send("Co ca ngua starts now~\nGame ID: {new_game.game_id}")
            embed = discord.Embed()
            embed.add_field(name="This round players", value="\n".join((f"{i+1}. {p.member.display_name} ({p.color})" for i, p in enumerate(new_game.players))))
            await ctx.send(embed=embed)
            await ctx.send(f"{new_game.current_player.member.mention}'s turn ({new_game.current_player.color}):")
        else:
            embed = discord.Embed(
                title="Co Ca Ngua",
                description=
                    "Simple Vietnamese board game, 2~4 players.\n"
                    "Each player is affiliated with a color, and possesses 4 horses.\n"
                    "Horses start at the big bold spot of their color, and move counter-clockwise.\n"
                    "You can't pass other horses, and horses can't be in the same spot, but your can kick other players' horses back to their stable.\n"
                    "The goal is to have all the horses climb to the highest possible spot on your tower.\n"
                    "The winner is the first one to do so.",
                colour=discord.Colour.purple()
            )
            embed.add_field(
                name="How to play",
                value=
                    "1. Players take turn roll the dices.\n"
                    "2. If the roll results are 6 and 1 or two same side then you get another roll.\n"
                    "3. If the roll results are 6 and 1 or two same side then you can let one of your horse out. Letting horse out consumes both roll results.\n"