コード例 #1
0
 async def on_raw_reaction_add(self, payload): # Reaction is added to message
     # Not on_reaction_add because of this weird assed queue of messages CHRIST i hate discord
     # Because discord can't save every message in RAM, this is what suffering looks like.
     guild = bot.get_guild(payload.guild_id)
     if guild is None:
         return
     member = guild.get_member(payload.user_id)
     if member.id == bot.user.id:
         return 
     emoji = payload.emoji
     chn_id = payload.channel_id
     msg_id = payload.message_id
     # Checks if the message is in the dict
     if react_map := self.data[chn_id][msg_id]:
         # Checks if the react is in the message
         try:
             role = guild.get_role(react_map[emoji.id])
         except KeyError: # If emoji is not in the message, ignore.
             return
         except commands.RoleNotFound as exc:
             print(exc.args[0])
             return
         # There should be another exception clause here for missing roles but f**k that shit
         # Toggle role addition/removal.
         msg = await guild.get_channel(chn_id).fetch_message(msg_id)
         if (last_react := react_timetable.get(member.id)) is not None:
             if (datetime.utcnow() - last_react).seconds < 2*60:
                 await msg.remove_reaction(emoji, member)
                 return
コード例 #2
0
 async def post_dailies(self):
     for guild_id, admin_id in zip(guild_whitelist, (CONST_ADMINS[1], CONST_AUTHOR[0])):
         guild = bot.get_guild(guild_id)
         if guild is None or guild.get_member(bot.user.id) is None:
             continue
         admin = guild.get_member(admin_id)
         embed = self.create_embed(guild, admin,
             'Counts may not be accurate if the bot has been stopped at any point during the day.',
             )
         self.daily_msg[guild_id].clear()
         self.daily_usr[guild_id].clear()
         await guild_config.log(
             guild, 'modlog',
             admin.mention if admin_id == CONST_ADMINS[1] else '',
             embed=embed,
             )
コード例 #3
0
 async def post_dailies(self):
     for guild_id, admin_id in zip(guild_whitelist,
                                   (CONST_ADMINS[1], CONST_AUTHOR[0])):
         guild = bot.get_guild(guild_id)
         if guild is None or guild.get_member(bot.user.id) is None:
             continue
         admin = guild.get_member(admin_id)
         now = datetime.utcnow()
         msg_counts = "\n".join(
             f'`{guild.get_channel(chan_id)}:` **{count}**'
             for chan_id, count in daily_msg[guild_id].most_common())
         embed = dc.Embed(
             color=admin.color,
             timestamp=now,
             description=
             f'**Message counts since midnight UTC or bot start:**\n\n{msg_counts}',
         )
         embed.set_author(name=f'Daily counts for {admin}',
                          icon_url=admin.avatar_url)
         embed.add_field(name='Users Gained:',
                         value=daily_usr[guild_id]['join'])
         embed.add_field(name='Users Lost:',
                         value=daily_usr[guild_id]['leave'])
         embed.add_field(
             name='**DISCLAIMER:**',
             value=
             'Counts may not be accurate if the bot has been stopped at any point during the day.',
             inline=False,
         )
         daily_msg[guild_id].clear()
         daily_usr[guild_id].clear()
         await guild_config.log(
             guild,
             'modlog',
             admin.mention if admin_id == CONST_ADMINS[1] else '',
             embed=embed,
         )
コード例 #4
0
 async def on_raw_reaction_clear(self, payload): # All reacts cleared from message
     # If all reacts from a message are removed, remove associated data if it exists.
     if (guild := bot.get_guild(payload.guild_id)) is None:
         return
コード例 #5
0
 async def on_raw_reaction_remove(self, payload): # Reaction is removed from message
     # If reacts from the bot are removed from messages under the role reacts, remove the associated data.
     if (guild := bot.get_guild(payload.guild_id)) is None:
         return