Beispiel #1
0
    def generate_prev_winners_msg(winners):
        if not winners:
            return ''

        return 'Previous giveaway winners:\n' + '\n'.join(
            [UserUtils.get_nick_or_name(winner) for
             winner in winners]) + '\n'
Beispiel #2
0
    async def giveaway_command(self, ctx):
        winners = self.client.global_variables.giveaway_winners
        log.info("Previous giveaway winners are: " + UserUtils.print_names(winners))
        channel = self.client.get_channel(Config.GIVEAWAY_VOICE_CHANNEL_ID)
        channel_members = channel.members
        log.info("Giveaway channel members are: " + UserUtils.print_names(channel_members))

        # channel_members = TestUtils.generate_players_list(14)
        # spectators = TestUtils.generate_players_list(3, UserUtils.IDLE)
        # channel_members.extend(spectators)

        prev_winners_msg = self.generate_prev_winners_msg(winners)
        contenders = ListUtils.remove_sub_list(channel_members, winners)
        log.info("Giveaway contenders are: " + UserUtils.print_names(contenders))
        if not contenders:
            log.info("No contenders for giveaway")
            await ctx.send(embed=discord.Embed(title=giveaway_title,
                                               description=prev_winners_msg + '\n' + "No contenders!",
                                               color=discord.Color.blue()))
            return

        player_lottery_msg = self.generate_players_lottery_msg(self, contenders)

        random_index = ListUtils.get_rand_index(contenders)
        new_winner = contenders[random_index]
        log.info("The new winner is: " + UserUtils.get_nick_or_name(new_winner))
        winners.append(new_winner)
        await ctx.send(embed=discord.Embed(title=giveaway_title,
                                           description=giveaway_desc.format(prev_winners_msg, player_lottery_msg,
                                                                            new_winner.mention),
                                           color=discord.Color.blue()))
Beispiel #3
0
 async def generate_members_in_bench_msg(bench):
     member_names = '\n'.join(
         [UserUtils.get_nick_or_name(m) for m in bench])
     return discord.Embed(title="{} member(s) in {}".format(
         len(bench), "Bench"),
                          description=member_names,
                          color=discord.Color.blue())
Beispiel #4
0
 def generate_team_embed_message(number_of_team, team):
     embed = discord.Embed(title="Team " + str(number_of_team) + " (" +
                           str(TeamUtils.get_team_avg_sr(team)) + " SR)",
                           color=0x00FF00)
     for x in range(0, len(team)):
         player = team[x]
         embed.add_field(name="Player " + str(x + 1) + ":",
                         value=UserUtils.get_nick_or_name(player),
                         inline=True)
     return embed
Beispiel #5
0
 def generate_players_lottery_msg(self, players):
     return 'Contenders:\n' + '\n'.join(
         [self.get_rand_declare_msg().format(UserUtils.get_nick_or_name(player)) for
          player in players])