Corrected the checking if the player was player2
This commit is contained in:
parent
8ba99ec277
commit
64cb718bb9
|
@ -6,10 +6,20 @@ import discord
|
|||
import random
|
||||
|
||||
|
||||
def battlingOff(m_id):
|
||||
battling = config.getContent('battling')
|
||||
del battling[m_id]
|
||||
config.saveContent('battling',battling)
|
||||
def battlingOff(player1 = None, player2 = None):
|
||||
if player1 is not None:
|
||||
battling = config.getContent('battling')
|
||||
del battling[player1]
|
||||
config.saveContent('battling',battling)
|
||||
else if player2 is not None:
|
||||
battling = config.getContent('battling')
|
||||
for p1_id,p2_id in battling:
|
||||
if p2_id = player2:
|
||||
del battling[p1_id]
|
||||
config.saveContent('battling',battling)
|
||||
break
|
||||
|
||||
|
||||
|
||||
def userBattling(ctx):
|
||||
battling = config.getContent('battling')
|
||||
|
@ -79,7 +89,7 @@ class Interaction:
|
|||
battling[ctx.message.author.id] = ctx.message.mentions[0].id
|
||||
config.saveContent('battling',battling)
|
||||
await self.bot.say(fmt.format(ctx.message.author, player2))
|
||||
t = Timer(180, battlingOff, ctx.message.author.id)
|
||||
t = Timer(180, battlingOff, {player1=ctx.message.author.id})
|
||||
t.start()
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
|
@ -94,12 +104,12 @@ class Interaction:
|
|||
await self.bot.say(fmt.format(battleP1.mention, battleP2.mention))
|
||||
if not updateBattleRecords(battleP1, battleP2):
|
||||
await self.bot.say("I was unable to save this data")
|
||||
battlingOff(ctx.message.author.id)
|
||||
battlingOff(player2 = ctx.message.author.id)
|
||||
elif num > 50:
|
||||
await self.bot.say(fmt.format(battleP2.mention, battleP1.mention))
|
||||
if not updateBattleRecords(battleP2, battleP1):
|
||||
await self.bot.say("I was unable to save this data")
|
||||
battlingOff(ctx.message.author.id)
|
||||
battlingOff(player2 = ctx.message.author.id)
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
@checks.customPermsOrRole("none")
|
||||
|
@ -110,7 +120,7 @@ class Interaction:
|
|||
await self.bot.say("{0} has chickened out! {1} wins by default!".format(battleP2.mention, battleP1.mention))
|
||||
if not updateBattleRecords(battleP1, battleP2):
|
||||
await self.bot.say("I was unable to save this data")
|
||||
battlingOff(ctx.message.author.id)
|
||||
battlingOff(player2 = ctx.message.author.id)
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
@checks.customPermsOrRole("none")
|
||||
|
|
Loading…
Reference in a new issue