示例#1
0
 async def add_reaction(self, message, emoji):
     if isinstance(emoji, str):
         emoji = str_to_emoji(emoji, self)
     state = message._state
     message._state = self._connection
     r = await message.add_reaction(emoji)
     message._state = state
     return r
示例#2
0
 async def remove_buttons(self, *emojis):
     channel_id = self.message.channel.id
     channel = self.module.get_channel(channel_id)
     # await channel.fetch_message(self.message.id)
     updated_message = await self.module.fetch_channel_message(
         channel, self.message.id)
     for emoji in emojis:
         if emoji in self.active_buttons:
             d_emoji = str_to_emoji(emoji, self.module)
             for reaction in updated_message.reactions:
                 if reaction.emoji == d_emoji:
                     await self.module.shared_clear_reaction(reaction)
                     self.active_buttons.remove(emoji)
示例#3
0
    async def render(self):
        # TODO: if needed make this method follow the order of the active_buttons list, actually not the case
        """Affiche le panel, ne fais rien si tout est déjà bon, ajouter les boutons et modifie l'embed au besoins"""
        self.is_rendering = True
        old_embed = self.message.embeds[0]
        new_embed = self.embed()
        if self.temp_notif is not None:
            # emoji = 'https://cdn.discordapp.com/emojis/737084672936509452.png'
            new_embed.set_footer(text=self.temp_notif)  # icon_url=emoji
            self.temp_notif = None

        # message modification if needed
        if old_embed.to_dict() != new_embed.to_dict():
            await self.module.edit_message(self.message, embed=new_embed)

        if self.is_disable:
            await self.module.shared_clear_reactions(self.message)
        elif self.active_buttons is None:
            self.active_buttons = []
            for emoji in self.base_buttons:
                await self.module.shared_add_reaction(
                    self.message, str_to_emoji(emoji, self.module))
                self.active_buttons.append(emoji)
        self.is_rendering = False
示例#4
0
 def get_emoji(self, name):
     return str_to_emoji(f':{name}', self.module)
示例#5
0
 def get_emoji(self, name):
     return str_to_emoji(f':{name}:', self)
示例#6
0
 def to_str(self,module):
     return "{} ┃ {} **×{}**".format(str_to_emoji(f':{self.item.emoji}:',module), self.item.display_name, self.quantity)
示例#7
0
 def short_str(self,module):
     return  "**{}×{}**".format(str_to_emoji(f':{self.item.emoji}:',module),self.quantity)
示例#8
0
    async def run(self):
        db_user = self.module.api.db_user(self.sender)
        try:
            voc_session = str(
                datetime.timedelta(
                    seconds=self.module.in_voc[self.sender]['duration']))
        except:
            voc_session = narr('me_command.no_voc_session')

        if db_user.inviter is not None:
            user = self.module.get_user(db_user.inviter.user_id)
            if user:
                inviter = user.mention  #display_name
            else:
                inviter = narr('me_command.unknown_inviter'
                               ) + f" [{db_user.inviter.user_id}]"
        else:
            inviter = narr('me_command.no_inviter')

        format_vars = {
            "money_key":
            narr('me_command.money_key'),
            "level_key":
            narr('me_command.level_key'),
            "xp_key":
            narr('me_command.xp_key'),
            "voc_session_key":
            narr('me_command.voc_session_key'),
            "message_key":
            narr('me_command.message_key'),
            "voc_key":
            narr('me_command.voc_key'),
            "energy_key":
            narr('me_command.energy_key'),
            "gem_key":
            narr('me_command.gem_key'),
            "gems":
            db_user.gems,
            "gem_emoji":
            str_to_emoji(':gem:', self.module),
            "inviter_key":
            narr('me_command.inviter'),
            "inviter":
            inviter,
            "energy":
            db_user.energy,
            "money_emoji":
            str_to_emoji(':money:', self.module),
            "money":
            db_user.money,
            "level":
            db_user.level,
            "xp":
            db_user.xp,
            "xp_needed":
            db_user.xp_needed,
            "xp_bar":
            emoji_bar(8, db_user.xp / db_user.xp_needed, '🟩', '⬛',
                      self.module),
            "energy_bar":
            emoji_bar(8, db_user.energy / db_user.energy_max, '🟨', '⬛',
                      self.module),
            "energy_max":
            db_user.energy_max,
            "total_message":
            db_user.message_sent,
            "total_voc":
            str(datetime.timedelta(seconds=db_user.vocal_time)),
            "voc_session":
            voc_session,
        }
        embed = discord.Embed(
            title=narr('me_command.title').format(
                name=self.sender.display_name),
            colour=discord.Colour.blurple(),
            description=USER_INFO_TEMPLATE.format(**format_vars))
        await self.module.send(self.channel, self.sender.mention, embed=embed)
示例#9
0
 async def add_buttons(self, *emojis):
     for emoji in emojis:
         if emoji not in self.active_buttons:
             await self.module.shared_add_reaction(
                 self.message, str_to_emoji(emoji, self.module))
             self.active_buttons.append(emoji)