Python discord 模块,Emoji() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用discord.Emoji()

项目:Tobo-Cogs    作者:Tobotimus    | 项目源码 | 文件源码
def _reaction_removed(self, reaction: discord.Reaction, user: discord.User):
        if self.setting_emojis: return # Don't change karma whilst adding/removing emojis
        server = reaction.message.server
        author = reaction.message.author
        if author == user: return # Users can't change their own karma
        emoji = reaction.emoji
        if isinstance(emoji, discord.Emoji):
            emoji = emoji.name
        else:
            emoji = name(emoji)
        try:
            if emoji == self.settings[server.id][UPVOTE]:
                self._add_karma(author.id, -1)
            elif emoji == self.settings[server.id][DOWNVOTE]:
                self._add_karma(author.id, 1)
        except:
            return
项目:Excalibot    作者:endreman0    | 项目源码 | 文件源码
def guild(self, ctx):
        """Retrieves information about this guild."""
        guild = ctx.guild
        e = discord.Embed(type='rich', color=blurple)
        e.set_thumbnail(url=guild.icon_url)
        e.add_field(name='Name', value=guild.name)
        e.add_field(name='ID', value=guild.id)
        e.add_field(name='Created at', value=guild.created_at.strftime(datetime_format))
        e.add_field(name='Owner', value=guild.owner)
        e.add_field(name='Members', value=guild.member_count)
        e.add_field(name='Channels', value=len(guild.channels))
        e.add_field(name='Roles', value=len(guild.role_hierarchy)-1) # Remove @everyone
        e.add_field(name='Emoji', value=len(guild.emojis))
        e.add_field(name='Region', value=guild.region.name)
        e.add_field(name='Icon URL', value=guild.icon_url or 'This guild has no icon.')
        await ctx.send(embed=e)
项目:Tobo-Cogs    作者:Tobotimus    | 项目源码 | 文件源码
def _reaction_added(self, reaction: discord.Reaction, user: discord.User):
        if self.setting_emojis: return # Don't change karma whilst adding/removing emojis
        server = reaction.message.server
        author = reaction.message.author
        if author == user: return # Users can't change their own karma
        emoji = reaction.emoji
        if isinstance(emoji, discord.Emoji):
            emoji = emoji.name
        else:
            emoji = name(emoji)
        try:
            if emoji == self.settings[server.id][UPVOTE]:
                self._add_karma(author.id, 1)
            elif emoji == self.settings[server.id][DOWNVOTE]:
                self._add_karma(author.id, -1)
        except:
            return
项目:PTSCogs    作者:PlanetTeamSpeakk    | 项目源码 | 文件源码
def emoteurl(self, *, emote:discord.Emoji):
        """Gets the url for a CUSTOM emote (meaning no emotes like :eyes: and :ok_hand:)"""
        await self.bot.say(emote.url)
项目:Sparcli    作者:4Kaylum    | 项目源码 | 文件源码
def permissions(self, ctx, member:Member=None):
        '''
        Checks what permissions a given user has in the mentioned channel
        '''

        # Checks for a tagged member
        if member == None:
            member = ctx.message.author 

        # ? TICK
        # ? CROSS
        # ?? ?

        w = {True:'??', False:'?'}

        # Store the channel
        channel = ctx.message.channel
        p = channel.permissions_for(member)
        o = OrderedDict()
        o['Read Messages'] = w[p.read_messages]
        o['Send Messages'] = w[p.send_messages]
        o['TTS'] = w[p.send_tts_messages]
        o['Manage Messages'] = w[p.manage_messages]
        o['Embed Links'] = w[p.embed_links]
        o['Attach Files'] = w[p.attach_files]
        o['Read Message History'] = w[p.read_message_history]
        o['Mention Everyone'] = w[p.mention_everyone]
        o['Change Nickanme'] = w[p.change_nickname]
        o['Manage Nicknames'] = w[p.manage_nicknames]
        o['Manage Roles'] = w[p.manage_roles]
        o['Manage Emoji'] = w[p.manage_emojis]
        o['Manage Channels'] = w[p.manage_channels]
        o['Kick Members'] = w[p.kick_members]
        o['Ban Members'] = w[p.ban_members]
        o['Administrator'] = w[p.administrator]

        e = makeEmbed(fields=o)
        await self.sparcli.say(embed=e)
项目:kitsuchan-2    作者:n303p4    | 项目源码 | 文件源码
def customemojiinfo(self, ctx, *, emoji: discord.Emoji):
        """Display information for a custom emoji.

        * emoji - The emoji to get information about."""

        embed = discord.Embed(title=emoji.name)
        embed.description = f"{emoji.id} | [Full image]({emoji.url})"

        embed.add_field(name="Guild", value=f"{emoji.guild.name} ({emoji.guild.id})")
        embed.add_field(name="Managed", value=emoji.managed)
        embed.add_field(name="Created at", value=emoji.created_at.ctime())

        embed.set_thumbnail(url=emoji.url)

        await ctx.send(embed=embed)
项目:DisKvlt-Bot    作者:MitchWeaver    | 项目源码 | 文件源码
def create_emoji(_name, _id): return Emoji(name=_name, id=_id, server=294213994787635200)
项目:pcbot    作者:pckv    | 项目源码 | 文件源码
def get_emote(emote_id: str, server: discord.Server):
    """ Return the image of a custom emote. """
    emote = discord.Emoji(id=emote_id, server=server)

    # Return the cached version if possible
    if emote.id in emote_cache:
        return Image.open(emote_cache[emote.id])

    # Otherwise, download the emote, store it in the cache and return
    emote_bytes = await utils.download_file(emote.url, bytesio=True)
    emote_cache[emote.id] = emote_bytes
    return Image.open(emote_bytes)
项目:dogbot    作者:slice    | 项目源码 | 文件源码
def on_guild_emojis_update(self, guild: discord.Guild, before: 'List[discord.Emoji]',
                                     after: 'List[discord.Emoji]'):

        added, removed = diff(before, after)
        if not added and not removed:
            # TODO: Handle renames
            return
        differences = describe_differences(self.bot, added, removed)
        await self.log(guild, f'\N{FRAME WITH PICTURE} Emoji updated: {differences}')
项目:Tobo-Cogs    作者:Tobotimus    | 项目源码 | 文件源码
def _create_emoji_list(reactions):
    for reaction in reactions:
        emoji = reaction.emoji
        if isinstance(emoji, discord.Emoji):
            emoji = emoji.name
        yield emoji
项目:Tobo-Cogs    作者:Tobotimus    | 项目源码 | 文件源码
def _set_reaction(self, server, reaction: discord.Reaction, type):
        emoji = reaction.emoji
        if isinstance(emoji, discord.Emoji):
            emoji = emoji.name
        else:
            emoji = name(emoji)
        if server.id not in self.settings: 
            self.settings[server.id] = {}
        self.settings[server.id][type] = emoji
        dataIO.save_json(SETTINGS_PATH, self.settings)
项目:Pesterchum-Discord    作者:henry232323    | 项目源码 | 文件源码
def fmt_emote(match, mobj):
        str = match.group(0)
        str = str[2:-1]
        name, id = str.split(":")
        emoji = discord.Emoji(id=id, server=mobj.server)
        fmt = '<img src="{}"/>'.format(emoji.url)
        return fmt
项目:Discord-SelfBot    作者:IgneelDxD    | 项目源码 | 文件源码
def regional(self, ctx, *, msg: str):
        """Convert a Text to emotes."""
        regional_list = self.to_regionals(msg, False)
        regional_output = []
        for i in regional_list:
            regional_output.append(" ")
            if isinstance(i, discord.Emoji):
                regional_output.append(str(i))
            else:
                regional_output.append(i)
        await edit(ctx, content=''.join(regional_output))
项目:Cassandra    作者:Avinch    | 项目源码 | 文件源码
def id_(self, ctx, *, argument: Union(Emoji, Role, TextChannel, VoiceChannel, Member, User)):
        await ctx.send(f"{argument.name}'s ID is {argument.id}")
项目:Excalibot    作者:endreman0    | 项目源码 | 文件源码
def emoji(self, ctx, emoji : FailsafeEmojiConverter):
        """Retrieves information about an emoji."""
        e = discord.Embed(type='rich', color=blurple)
        if isinstance(emoji, discord.Emoji):
            url = emoji.url.replace('discordapp.com/api', 'cdn.discordapp.com')
            e.set_thumbnail(url=url)
            e.add_field(name='Name', value=emoji.name)
            e.add_field(name='ID', value=emoji.id)
            e.add_field(name='Created at', value=emoji.created_at.strftime(datetime_format))
            e.add_field(name='URL', value=url)
        else:
            e.add_field(name='Name', value=unicodedata.name(emoji))
            e.add_field(name='ID', value='Built-in')
        await ctx.send(embed=e)
项目:dogbot    作者:slice    | 项目源码 | 文件源码
def describe(thing: Any, *, mention=False, before='', created=False, joined=False, quote=False):
    """
    Returns a string representing an project. Usually consists of the object in string form,
    then the object's ID in parentheses after.

    Parameters
    ----------
    thing
        The thing to describe. Usually a superclass of :class:`discord.Object`.
    mention
        Specifies whether to mention the thing instead of using its string representation.
    before
        Specifies text to insert after name and ID.
    created
        Specifies whether to append the ``created_at`` attribute, post-processed with :func:`ago`.
    joined
        Specifies whether to append the ``joined_at`` attribute, post-processed with :func:`ago`.
    quote
        Specifies whether to quote the name of the thing.
    """

    # get name, might be mention
    name = str(thing) if not mention else thing.mention

    # handle emoji specially
    if isinstance(thing, discord.Emoji):
        name = f'`{":" + thing.name + ":" if thing.require_colons else thing.name}`'

    if quote:
        name = '"' + name + '"'

    # name + id
    message = f'{name} (`{thing.id}`)'

    # objects have id only
    if isinstance(thing, discord.Object):
        message = f'`{thing.id}`'

    if before:
        message += ' ' + before
    if created:
        message += f', created {ago(thing.created_at)}'
    if joined and isinstance(thing, discord.Member):
        message += f', joined {ago(thing.joined_at)}'
    return message