I'm making a discord bot so that I can make tournaments for League 5v5. Here is the command I made for making the teams:
rows, cols = 5, 2
teamArr = [["Empty" for x in range(rows)] for y in range(cols)]
teamNum = ""
playerName = ""
lane = ""
@bot.command()
async def team(context, name, num, pos): #member: discord.Member
teamEmbed = discord.Embed(title="Teams", color=0x6a0dad)
playerName = str(name)
teamNum = str(num)
lane = str(pos)
#team1
if (teamNum == 1):
if (lane == 'Top'):
teamArr[0][0] = str(playerName)
elif (lane == 'Jungle'):
teamArr[0][1] = str(playerName)
elif (lane == 'Mid'):
teamArr[0][2] = str(playerName)
elif (lane == 'Adc'):
teamArr[0][3] = str(playerName)
elif (lane == 'Support'):
teamArr[0][4] = str(playerName)
#team2
elif (teamNum == 2):
if (lane == 'Top'):
teamArr[1][0] = str(playerName)
elif (lane == 'Jungle'):
teamArr[1][1] = str(playerName)
elif (lane == 'Mid'):
teamArr[1][2] = str(playerName)
elif (lane == 'Adc'):
teamArr[1][3] = str(playerName)
elif (lane == 'Support'):
teamArr[1][4] = str(playerName)
teamResult = str(teamArr[0][0]) + "\n" + str(teamArr[0][1]) + "\n" + str(teamArr[0][2]) + "\n" + str(teamArr[0][3]) + "\n" + str(teamArr[0][4])
teamEmbed.add_field(name="Team 1", value=teamResult, inline=True)
teamResult2 = str(teamArr[1][0]) + "\n" + str(teamArr[1][1]) + "\n" + str(teamArr[1][2]) + "\n" + str(teamArr[1][3]) + "\n" + str(teamArr[1][4])
teamEmbed.add_field(name="Team 2", value=teamResult2, inline=True)
await context.send(embed=teamEmbed)
I made the teamArr with all the elements to be "Empty." I am setting teamArr[0][0] = playerName so that I am changing the string "Empty" to the player's name. However, whenever I print it out, it just stays as "Empty" and does not seem to work. What would I be possibly doing wrong here?
You are setting
teamNum = str(num)
but then comparingteamNum == 1
andteamNum == 2
. Therefore, neither comparison is correct, and your code skips to the end. You can fix this by doing something such asint(teamNum) == 1
orteamNum == '1'
.Sidenotes:
async def team(ctx, name: str, num: int, lane: str)
. There's also no need tostr()
everything multiple times.'\n'.join(teamArr[0])
.teamArr[teamNum-1]
instead of writing it twice.