reactions.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Harmonbot 作者: Harmon758 项目源码 文件源码
def mazer_processr(self, player, reaction, user):
        if user == player and reaction.emoji in tuple(self.arrows.keys()) + ("\N{PRINTER}",):
            maze_instance = self.mazes[reaction.message.id]
            if reaction.emoji == "\N{PRINTER}":
                with open("data/temp/maze.txt", 'w') as maze_file:
                    maze_file.write('\n'.join(maze_instance.visible))
                await self.bot.send_file(reaction.message.channel, "data/temp/maze.txt", content = "{}:\nYour maze is attached".format(player.display_name))
                return
            embed = discord.Embed(color = clients.bot_color)
            avatar = player.avatar_url or player.default_avatar_url
            embed.set_author(name = player.display_name, icon_url = avatar)
            moved = maze_instance.move(self.arrows[reaction.emoji].lower())
            embed.set_footer(text = "Your current position: {}, {}".format(maze_instance.column + 1, maze_instance.row + 1))
            if moved:
                if maze_instance.reached_end():
                    embed.description = "{}\nCongratulations! You reached the end of the maze in {} moves".format(clients.code_block.format(maze_instance.print_visible()), maze_instance.move_counter)
                    del self.reaction_messages[reaction.message.id]
                else:
                    embed.description = "{}".format(clients.code_block.format(maze_instance.print_visible()))
            else:
                embed.description = "{}\n:no_entry: You can't go that way".format(clients.code_block.format(maze_instance.print_visible()))
            await self.bot.edit_message(reaction.message, embed = embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号