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


Python discord.RawReactionActionEvent方法代码示例

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


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

示例1: on_raw_reaction_remove

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent) -> None:
        """
            Checks for reactions to the event
        """
        if str(payload.emoji) not in EVENT_EMOJIS:
            # log.debug("Not a valid yes or no emoji")
            return
        if payload.guild_id not in self.event_cache:
            return
        if payload.message_id not in self.event_cache[payload.guild_id]:
            return

        guild = self.bot.get_guild(payload.guild_id)
        user = guild.get_member(payload.user_id)
        if user.bot:
            return
        event = self.event_cache[payload.guild_id][payload.message_id]
        if str(payload.emoji) == "\N{WHITE HEAVY CHECK MARK}":
            if user == event.hoster:
                return
            await self.remove_user_from_event(user, event)
        if str(payload.emoji) == "\N{WHITE QUESTION MARK ORNAMENT}":
            if user == event.hoster:
                return
            await self.remove_user_from_event(user, event) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:27,代码来源:eventposter.py

示例2: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):
        user: discord.User = self.bot.get_user(int(payload.user_id))
        guild: discord.Guild = self.bot.config.get("GUILD_ID")

        if user.bot:
            return

        member: discord.Member = await guild.fetch_member(payload.user_id)

        if member is None:
            return

        if payload.emoji.name in self.roles or payload.emoji.id in self.roles:
            role = await guild.get_role(
                self.roles[payload.emoji.name or payload.emoji.id]
            )
            await member.add_roles(role) 
开发者ID:officialpiyush,项目名称:modmail-plugins,代码行数:19,代码来源:rolereaction.py

示例3: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload: RawReactionActionEvent) -> None:
        """
        Determine if a message should be sent to the duck pond.

        This will count the number of duck reactions on the message, and if this amount meets the
        amount of ducks specified in the config under duck_pond/threshold, it will
        send the message off to the duck pond.
        """
        # Is the emoji in the reaction a duck?
        if not self._payload_has_duckpond_emoji(payload):
            return

        channel = discord.utils.get(self.bot.get_all_channels(), id=payload.channel_id)
        message = await channel.fetch_message(payload.message_id)
        member = discord.utils.get(message.guild.members, id=payload.user_id)

        # Is the member a human and a staff member?
        if not self.is_staff(member) or member.bot:
            return

        # Does the message already have a green checkmark?
        if await self.has_green_checkmark(message):
            return

        # Time to count our ducks!
        duck_count = await self.count_ducks(message)

        # If we've got more than the required amount of ducks, send the message to the duck_pond.
        if duck_count >= constants.DuckPond.threshold:
            await self.relay_message(message) 
开发者ID:python-discord,项目名称:bot,代码行数:32,代码来源:duck_pond.py

示例4: on_raw_reaction_remove

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_remove(self, payload: RawReactionActionEvent) -> None:
        """Ensure that people don't remove the green checkmark from duck ponded messages."""
        channel = discord.utils.get(self.bot.get_all_channels(), id=payload.channel_id)

        # Prevent the green checkmark from being removed
        if payload.emoji.name == "✅":
            message = await channel.fetch_message(payload.message_id)
            duck_count = await self.count_ducks(message)
            if duck_count >= constants.DuckPond.threshold:
                await message.add_reaction("✅") 
开发者ID:python-discord,项目名称:bot,代码行数:12,代码来源:duck_pond.py

示例5: handle_raw_reaction

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def handle_raw_reaction(self, payload: RawReactionActionEvent,
                                  added: bool):
        chan = await self.bot.fetch_channel(payload.channel_id)
        try:
            msg = await chan.fetch_message(payload.message_id)
            usr = await self.bot.fetch_user(payload.user_id)
        except NotFound:
            return False

        for r in msg.reactions:
            if str(r.emoji) == str(payload.emoji):
                await self.voter.handle_reaction(r, usr, added)
                return True

        return False 
开发者ID:Toaster192,项目名称:rubbergod,代码行数:17,代码来源:vote.py

示例6: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload: RawReactionActionEvent):
        if self.__handle(payload.message_id, payload.user_id, payload.emoji,
                         True, True):
            # print("Already handled (in RAW)")
            return

        # print("Handling RAW")
        try:
            if not await self.handle_raw_reaction(payload, True):
                print("Couldn't find reaction, that is rather weird.")
        except HTTPException:
            # ignore HTTP Exceptions
            return 
开发者ID:Toaster192,项目名称:rubbergod,代码行数:15,代码来源:vote.py

示例7: on_raw_reaction_remove

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_remove(self, payload: RawReactionActionEvent):
        if self.__handle(payload.message_id, payload.user_id, payload.emoji,
                         False, True):
            # print("Already handled (in RAW)")
            return

        # print("Handling RAW")
        if not await self.handle_raw_reaction(payload, False):
            print("Couldn't find reaction, that is rather weird.") 
开发者ID:Toaster192,项目名称:rubbergod,代码行数:11,代码来源:vote.py

示例8: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload):
        """
        Starts events when a user adds an emote reaction to a message regardless of it being cached.
        :type payload: discord.RawReactionActionEvent
        :param payload: The raw reaction addition event payload.
        :return:
        """
        if payload.user_id != payload.channel_id:
            payload = RawReactionPayload(self, payload)
            self.loop.create_task(self.queue.event_runner('raw_reaction_add', payload))
            if str(payload.raw.emoji) in ['⬅', '➡']:
                self.loop.create_task(self.queue.event_runner('raw_paginate', payload)) 
开发者ID:lu-ci,项目名称:apex-sigma-core,代码行数:14,代码来源:sigma.py

示例9: on_raw_reaction_remove

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_remove(self, payload):
        """
        Starts events when a user removes an emote reaction from a message regardless of it being cached.
        :type payload: discord.RawReactionActionEvent
        :param payload: The raw reaction removal event payload.
        :return:
        """
        if payload.user_id != payload.channel_id:
            self.loop.create_task(self.queue.event_runner('raw_reaction_remove', RawReactionPayload(self, payload))) 
开发者ID:lu-ci,项目名称:apex-sigma-core,代码行数:11,代码来源:sigma.py

示例10: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) -> None:
        """
            Checks for reactions to the event
        """
        if str(payload.emoji) not in EVENT_EMOJIS:
            # log.debug("Not a valid yes or no emoji")
            return
        if payload.guild_id not in self.event_cache:
            return
        if payload.message_id not in self.event_cache[payload.guild_id]:
            return

        guild = self.bot.get_guild(payload.guild_id)
        user = guild.get_member(payload.user_id)
        if user.bot:
            return
        event = self.event_cache[payload.guild_id][payload.message_id]
        if str(payload.emoji) == "\N{WHITE HEAVY CHECK MARK}":
            await self.add_user_to_event(user, event)
        if str(payload.emoji) == "\N{WHITE QUESTION MARK ORNAMENT}":
            await self.add_user_to_maybe(user, event)
        if str(payload.emoji) == "\N{NEGATIVE SQUARED CROSS MARK}":
            if user == event.hoster:
                async with self.config.guild(guild).events() as events:
                    event = await Event.from_json(events[str(user.id)], guild)
                    await event.message.edit(content="This event has ended.")
                    del events[str(user.id)]
                    del self.event_cache[guild.id][event.message.id]
                return
            await self.remove_user_from_event(user, event) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:32,代码来源:eventposter.py

示例11: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) -> None:
        await self._update_stars(payload) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:4,代码来源:events.py

示例12: on_raw_reaction_remove

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent) -> None:
        await self._update_stars(payload) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:4,代码来源:events.py

示例13: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):

        await asyncio.sleep(1)

        if str(payload.message_id) not in self.ids:
            return

        guild: discord.Guild = self.bot.main_guild

        if payload.user_id == self.bot.user.id:
            return

        member_id = int(guild.get_channel(payload.channel_id).topic[9:])

        role = (await self.db.find_one({"_id": "role-config"}))["emoji"][
            f"<:{payload.emoji.name}:{payload.emoji.id}>"
        ]

        role = discord.utils.get(guild.roles, name=role)

        if role is None:
            return await guild.get_channel(payload.channel_id).send("I couldn't find that role...")

        for m in guild.members:
            if m.id == member_id:
                member = m
            else:
                continue

        await member.add_roles(role)
        await guild.get_channel(payload.channel_id).send(
            f"Successfully added {role} to {member.name}"
        ) 
开发者ID:officialpiyush,项目名称:modmail-plugins,代码行数:35,代码来源:role-assignment.py

示例14: on_raw_reaction_remove

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent):
        await self.handleReaction(payload=payload) 
开发者ID:officialpiyush,项目名称:modmail-plugins,代码行数:4,代码来源:starboard.py

示例15: on_raw_reaction_add

# 需要导入模块: import discord [as 别名]
# 或者: from discord import RawReactionActionEvent [as 别名]
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):
        await self.handleReaction(payload=payload) 
开发者ID:officialpiyush,项目名称:modmail-plugins,代码行数:4,代码来源:starboard.py


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