Exemplo n.º 1
0
 async def refresh_betting_message(self):
     for guild in self.bot.guilds:
         games = GamblingUtil.get_active_games(guild.id)
         game: GamblingGame
         for game in games:
             channel = game.guild_id
             massage = await channel.fetch_message(game.message_id)
             embed = self.get_betting_embed(game)
             await massage.edit(embed=embed)
    def test_getActiveGameList(self):
        game1: GamblingGame = GamblingUtil.create_game(123, "new_game1", 5,
                                                       ["hello", "hi"], 123)
        game2: GamblingGame = GamblingUtil.create_game(123, "new_game2", 5,
                                                       ["hello", "hi"], 123)
        gameList = GamblingUtil.get_active_games(123)
        assert len(gameList) == 0

        GamblingUtil.update_game_status(game1, Util.GamblingStatus.ready, 123,
                                        321)
        gameList = GamblingUtil.get_active_games(123)
        assert len(gameList) == 1

        GamblingUtil.update_game_status(game2, Util.GamblingStatus.ready, 123,
                                        321)
        gameList = GamblingUtil.get_active_games(123)
        assert len(gameList) == 2
        assert gameList == [game1, game2]
Exemplo n.º 3
0
 async def betting_list_command(self, ctx: commands.Context, *argv):
     guild = ctx.guild
     game_list = GamblingUtil.get_active_games(guild.id)
     if len(game_list) == 0:
         return
     embed = Embed()
     embed.title = '賭盤列表'
     game: GamblingGame
     for game in game_list:
         channel = ctx.channel
         embed.add_field(
             name=game.name,
             value='每注: {}, 獎金池: {}, 狀態: {}\n頻道: <#{}>, 伺服器:{}'.format(
                 game.base, game.pool, game.status.name, channel.id,
                 guild.name),
             inline=False)
     await ctx.channel.send(embed=embed)