Python discord.RawReactionActionEvent() Examples
The following are 27
code examples of discord.RawReactionActionEvent().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
discord
, or try the search function
.
Example #1
Source File: eventposter.py From Trusty-cogs with MIT License | 7 votes |
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)
Example #2
Source File: role-assignment.py From modmail-plugins with GNU General Public License v3.0 | 5 votes |
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}" )
Example #3
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def queue_command(self, payload: discord.RawReactionActionEvent): """Player queue button.""" ctx = self.update_context(payload) command = self.bot.get_command('queue') ctx.command = command await self.bot.invoke(ctx)
Example #4
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def voldown_command(self, payload: discord.RawReactionActionEvent): """Volume down button.""" ctx = self.update_context(payload) command = self.bot.get_command('vol_down') ctx.command = command await self.bot.invoke(ctx)
Example #5
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def volup_command(self, payload: discord.RawReactionActionEvent): """Volume up button""" ctx = self.update_context(payload) command = self.bot.get_command('vol_up') ctx.command = command await self.bot.invoke(ctx)
Example #6
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def shuffle_command(self, payload: discord.RawReactionActionEvent): """Shuffle button.""" ctx = self.update_context(payload) command = self.bot.get_command('shuffle') ctx.command = command await self.bot.invoke(ctx)
Example #7
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def stop_command(self, payload: discord.RawReactionActionEvent): """Stop button.""" ctx = self.update_context(payload) command = self.bot.get_command('stop') ctx.command = command await self.bot.invoke(ctx)
Example #8
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def pause_command(self, payload: discord.RawReactionActionEvent): """Pause button""" ctx = self.update_context(payload) command = self.bot.get_command('pause') ctx.command = command await self.bot.invoke(ctx)
Example #9
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def resume_command(self, payload: discord.RawReactionActionEvent): """Resume button.""" ctx = self.update_context(payload) command = self.bot.get_command('resume') ctx.command = command await self.bot.invoke(ctx)
Example #10
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def reaction_check(self, payload: discord.RawReactionActionEvent): if payload.event_type == 'REACTION_REMOVE': return False if not payload.member: return False if payload.member.bot: return False if payload.message_id != self.message.id: return False if payload.member not in self.bot.get_channel(int(self.player.channel_id)).members: return False return payload.emoji in self.buttons
Example #11
Source File: advanced.py From Wavelink with MIT License | 5 votes |
def update_context(self, payload: discord.RawReactionActionEvent): """Update our context with the user who reacted.""" ctx = copy.copy(self.ctx) ctx.author = payload.member return ctx
Example #12
Source File: starboard.py From modmail-plugins with GNU General Public License v3.0 | 5 votes |
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent): await self.handleReaction(payload=payload)
Example #13
Source File: starboard.py From modmail-plugins with GNU General Public License v3.0 | 5 votes |
def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent): await self.handleReaction(payload=payload)
Example #14
Source File: rolereaction.py From modmail-plugins with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: duck_pond.py From bot with MIT License | 5 votes |
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)
Example #16
Source File: events.py From Trusty-cogs with MIT License | 5 votes |
def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent) -> None: await self._update_stars(payload)
Example #17
Source File: events.py From Trusty-cogs with MIT License | 5 votes |
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) -> None: await self._update_stars(payload)
Example #18
Source File: eventposter.py From Trusty-cogs with MIT License | 5 votes |
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)
Example #19
Source File: sigma.py From apex-sigma-core with GNU General Public License v3.0 | 5 votes |
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)))
Example #20
Source File: sigma.py From apex-sigma-core with GNU General Public License v3.0 | 5 votes |
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))
Example #21
Source File: vote.py From rubbergod with GNU General Public License v3.0 | 5 votes |
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.")
Example #22
Source File: vote.py From rubbergod with GNU General Public License v3.0 | 5 votes |
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
Example #23
Source File: vote.py From rubbergod with GNU General Public License v3.0 | 5 votes |
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
Example #24
Source File: duck_pond.py From bot with MIT License | 5 votes |
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("✅")
Example #25
Source File: report-user.py From modmail-plugins with GNU General Public License v3.0 | 4 votes |
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent): if payload.user_id == self.bot.user.id: return if ( str(payload.channel_id) != str(self.channel) or str(payload.emoji.name) != "✅" ): return channel: discord.TextChannel = self.bot.get_channel(payload.channel_id) msg: discord.Message = await channel.fetch_message(payload.message_id) if not msg.embeds or msg.embeds[0] is None: return if msg.embeds[0].footer.text is None: return case = int(msg.embeds[0].footer.text[5:]) casedb = await self.db.find_one({"case": case}) if casedb is None: return if casedb["resolved"] is True: await channel.send(f"Case `#{case}`Already resolved.") return def check(messge: discord.Message): return ( payload.user_id == messge.author.id and payload.channel_id == messge.channel.id ) await channel.send("Enter Your Report which will be sent to the reporter") reportr = await self.bot.wait_for("message", check=check) user1 = self.bot.get_user(int(casedb["author"])) await user1.send(f"**Reply From Staff Team:**\n{reportr.content}") await channel.send("DM'd") await self.db.find_one_and_update({"case": case}, {"$set": {"resolved": True}}) return
Example #26
Source File: events.py From Trusty-cogs with MIT License | 4 votes |
def _loop_messages( self, payload: discord.RawReactionActionEvent, starboard: StarboardEntry, star_channel: discord.TextChannel, message: discord.Message, ): try: guild = star_channel.guild except AttributeError: return for messages in (StarboardMessage.from_json(m) for m in starboard.messages): same_message = messages.original_message == message.id same_channel = messages.original_channel == payload.channel_id starboard_message = messages.new_message == message.id starboard_channel = messages.new_channel == payload.channel_id if not messages.new_message or not messages.new_channel: continue if (same_message and same_channel) or (starboard_message and starboard_channel): count = await self._get_count(messages, starboard) try: message_edit = await star_channel.fetch_message(messages.new_message) except AttributeError: message_edit = await star_channel.get_message(messages.new_message) # type: ignore # This is for backwards compatibility for older Red except (discord.errors.NotFound, discord.errors.Forbidden): # starboard message may have been deleted return True if count < starboard.threshold: star_message = StarboardMessage( message.id, payload.channel_id, None, None, message.author.id ) if messages.to_json() in starboard.messages: starboard.messages.remove(messages.to_json()) starboard.messages.append(star_message.to_json()) await self._save_starboards(guild) await message_edit.delete() return True count_message = f"{starboard.emoji} **#{count}**" await message_edit.edit(content=count_message) return True return False
Example #27
Source File: api.py From Trusty-cogs with MIT License | 4 votes |
def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) -> None: """ Translates the message based off reactions with country flags """ if version_info >= VersionInfo.from_str("3.2.0"): await self.bot.wait_until_red_ready() else: await self.bot.wait_until_ready() if payload.message_id in self.cache["translations"]: return if str(payload.emoji) not in FLAGS: return if not await self._get_google_api_key(): return channel = self.bot.get_channel(id=payload.channel_id) if not channel: return try: guild = channel.guild except AttributeError: return if guild is None: return reacted_user = guild.get_member(payload.user_id) if reacted_user.bot: return if not await self.check_bw_list(guild, channel, reacted_user): return if guild.id not in self.cache["guild_reactions"]: if not await self.config.guild(guild).reaction(): return else: self.cache["guild_reactions"].append(guild.id) if not await self.local_perms(guild, reacted_user): return if not await self.global_perms(reacted_user): return try: message = await channel.fetch_message(id=payload.message_id) except AttributeError: message = await channel.get_message(id=payload.message_id) except (discord.errors.NotFound, discord.Forbidden): return if not await self.check_ignored_channel(message): return await self.translate_message(message, str(payload.emoji), reacted_user)