当前位置: 首页>>代码示例>>Python>>正文


Python discord.PartialEmoji方法代码示例

本文整理汇总了Python中discord.PartialEmoji方法的典型用法代码示例。如果您正苦于以下问题:Python discord.PartialEmoji方法的具体用法?Python discord.PartialEmoji怎么用?Python discord.PartialEmoji使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord的用法示例。


在下文中一共展示了discord.PartialEmoji方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: emote_reaction_handle

# 需要导入模块: import discord [as 别名]
# 或者: from discord import PartialEmoji [as 别名]
def emote_reaction_handle(self, event: RawReactionActionEvent, handle):
        message_id: str = str(event.message_id)
        emoji: PartialEmoji = event.emoji
        if emoji.is_unicode_emoji():
            emoji = str(emoji)
        else:
            emoji = emoji.id
        guild: Guild = self.bot.get_guild(event.guild_id)
        user: Member = guild.get_member(event.user_id)
        action_query: ModelSelect = ReactionAction.select().where((ReactionAction.emoji == emoji) &
                                                                  (ReactionAction.message_id == message_id))
        if not action_query.exists():
            return
        action: ReactionAction = action_query.get()
        role_id = action.role_id
        role: Role = discord.utils.get(guild.roles,
                                       id=int(role_id))
        if role is None:
            print('Role not found.')
            return
        await handle(user, role, reason='Self roles') 
开发者ID:BaseChip,项目名称:RulesBot,代码行数:23,代码来源:reactions.py

示例2: convert

# 需要导入模块: import discord [as 别名]
# 或者: from discord import PartialEmoji [as 别名]
def convert(self, ctx, argument):
        match = re.match(r'<(a?):([a-zA-Z0-9\_]+):([0-9]+)>$', argument)

        if match:
            emoji_animated = bool(match.group(1))
            emoji_name = match.group(2)
            emoji_id = int(match.group(3))

            return discord.PartialEmoji.with_state(ctx.bot._connection, animated=emoji_animated, name=emoji_name,
                                                   id=emoji_id)

        raise BadArgument('Couldn\'t convert "{}" to PartialEmoji.'.format(argument)) 
开发者ID:Rapptz,项目名称:discord.py,代码行数:14,代码来源:converter.py

示例3: url

# 需要导入模块: import discord [as 别名]
# 或者: from discord import PartialEmoji [as 别名]
def url(id, *, animated: bool = False):
	"""Convert an emote ID to the image URL for that emote."""
	return str(discord.PartialEmoji(animated=animated, name='', id=id).url)

# remove when d.py v1.3.0 drops 
开发者ID:EmoteBot,项目名称:EmoteCollector,代码行数:7,代码来源:emote.py

示例4: steal_these

# 需要导入模块: import discord [as 别名]
# 或者: from discord import PartialEmoji [as 别名]
def steal_these(self, context, *emotes):
		"""Steal a bunch of custom emotes."""

		# format is: {(order, error_message_format_string): emotes_that_had_that_error}
		# no error: key=None
		# HTTP error: key=HTTP status code
		messages = {}
		# we could use *emotes: discord.PartialEmoji here but that would require spaces between each emote.
		# and would fail if any arguments were not valid emotes
		for match in re.finditer(utils.lexer.t_CUSTOM_EMOTE, ''.join(emotes)):
			animated, name, id = match.groups()
			image_url = utils.emote.url(id, animated=animated)
			async with context.typing():
				arg = fr'\:{name}:'

				try:
					emote = await self.add_from_url(name, image_url, context.author.id)
				except BaseException as error:
					messages.setdefault(self._humanize_errors(error), []).append(arg)
				else:
					messages.setdefault((0, _('**Successfully created:**')), []).append(str(emote))

		if not messages:
			return await context.send(_('Error: no existing custom emotes were provided.'))

		messages = sorted(messages.items())
		message = self._format_errors(messages)
		await context.send(message) 
开发者ID:EmoteBot,项目名称:EmoteCollector,代码行数:30,代码来源:emote.py

示例5: __eq__

# 需要导入模块: import discord [as 别名]
# 或者: from discord import PartialEmoji [as 别名]
def __eq__(self, other):
		return self.id == other.id and isinstance(other, (type(self), discord.PartialEmoji, discord.Emoji)) 
开发者ID:EmoteBot,项目名称:EmoteCollector,代码行数:4,代码来源:db.py

示例6: emoji_reaction

# 需要导入模块: import discord [as 别名]
# 或者: from discord import PartialEmoji [as 别名]
def emoji_reaction(self, text: str) -> PartialEmoji:
        await self.ctx.send(
            embed=Embed(
                color=Color.blurple(),
                description=text))

        def check(reaction: Reaction, user: User):
            message: Message = reaction.message
            return message.channel == self.message.channel and user.id == self.message.author.id

        try:
            reaction, user = await self.bot.wait_for('reaction_add', check=check, timeout=30)
            return reaction
        except asyncio.TimeoutError:
            raise AwaitTimedOut 
开发者ID:BaseChip,项目名称:RulesBot,代码行数:17,代码来源:awaiter.py

示例7: emoji

# 需要导入模块: import discord [as 别名]
# 或者: from discord import PartialEmoji [as 别名]
def emoji(
        self, ctx: commands.Context, emoji: Union[discord.Emoji, discord.PartialEmoji, str]
    ) -> None:
        """
            Post a large size emojis in chat
        """
        await ctx.channel.trigger_typing()
        if type(emoji) in [discord.PartialEmoji, discord.Emoji]:
            d_emoji = cast(discord.Emoji, emoji)
            ext = "gif" if d_emoji.animated else "png"
            url = "https://cdn.discordapp.com/emojis/{id}.{ext}?v=1".format(id=d_emoji.id, ext=ext)
            filename = "{name}.{ext}".format(name=d_emoji.name, ext=ext)
        else:
            try:
                """https://github.com/glasnt/emojificate/blob/master/emojificate/filter.py"""
                cdn_fmt = "https://twemoji.maxcdn.com/2/72x72/{codepoint:x}.png"
                url = cdn_fmt.format(codepoint=ord(str(emoji)))
                filename = "emoji.png"
            except TypeError:
                await ctx.send(_("That doesn't appear to be a valid emoji"))
                return
        try:
            async with aiohttp.ClientSession() as session:
                async with session.get(url) as resp:
                    image = BytesIO(await resp.read())
        except Exception:
            await ctx.send(_("That doesn't appear to be a valid emoji"))
            return
        file = discord.File(image, filename=filename)
        await ctx.send(file=file) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:32,代码来源:serverstats.py


注:本文中的discord.PartialEmoji方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。