Issue present with Purge command

This commit is contained in:
2021-07-21 23:05:13 +01:00
parent f1d12691c0
commit 51513c89a0
13 changed files with 90 additions and 25 deletions

View File

@ -337,7 +337,7 @@ class Configuration(commands.Cog, name='Configuration Commands'):
if role.id in conf[guildStr]['membership']:
await ctx.send(f'```The role {name} has already been assigned to a membership type for guild `{ctx.guild.name}`. Please use the `remove` sub-command to delete it or assign a different role.```',hidden=True)
return
if any([ctx.guild.get_role(m).name == name for m in conf[guildStr]['membership']]):
if any([ctx.guild.get_role(m).name == name for m in conf[str(ctx.guild.id)]['membership']]):
await ctx.send(f'```The membership type {name} has already been assigned a role for guild `{ctx.guild.name}`. Please use the `remove` sub-command to delete the role or assign a different membership type.```',hidden=True)
return
if not role_exists:

View File

@ -222,7 +222,7 @@ class GameManagement(commands.Cog, name='Game Management'):
if not data[guildStr][old_time]:
del data[guildStr][old_time]
if game_title and game_title != old_data['game_title']:
if game_title in [x['game_title'] for x in lookup[guildStr].values()] and time in [x['time'] for x in lookup[guildStr].values()]:
if game_title in [x['game_title'] for x in lookup[str(ctx.guild.id)].values()] and time in [x['time'] for x in lookup[str(ctx.guild.id)].values()]:
await ctx.send(f'```The target game `{game_title}` has already been created for the time slot `{conf[guildStr]["timeslots"][time]}`. Please avoud duplicates, or use the `modify` sub-command to edit the existing game.```',hidden=True)
return
result = ''.join([result,f"The game's title has been updated to {game_title}\n"])
@ -418,7 +418,7 @@ class GameManagement(commands.Cog, name='Game Management'):
if 'timeslots' not in conf[guildStr]:
conf[guildStr]['timeslots'] = {}
tsDict = {k: conf[guildStr]['timeslots'][k] for k in conf[guildStr]['timeslots'] if data[k]}
tsDict = {k: conf[guildStr]['timeslots'][k] for k in conf[guildStr]['timeslots'] if data[guildStr][k]}
optionsList = [create_select_option(label=tsDict[x], value=x, description=x) for x in tsDict].insert(0, create_select_option(label='All Timeslots', value='--all', description='--all'))
try:
m = await ctx.send(

View File

@ -133,7 +133,7 @@ class GameSetup(commands.Cog, name='Game Setup'):
return
if guildStr not in lookup:
lookup[guildStr] = {}
if game_title in [x['game_title'] for x in lookup[guildStr].values()] and time in [x['time'] for x in lookup[guildStr].values()]:
if game_title in [x['game_title'] for x in lookup[str(ctx.guild.id)].values()] and time in [x['time'] for x in lookup[str(ctx.guild.id)].values()]:
await ctx.send(f'```Game `{game_title}` has already been created for the time slot `{conf[guildStr]["timeslots"][time]}`. Please avoud duplicates, or use the `modify` sub-command to edit the existing game.```',hidden=True)
return
if guildStr not in data:
@ -241,7 +241,7 @@ class GameSetup(commands.Cog, name='Game Setup'):
result = ''.join([result,f'There was already a channel category that matched the game, so it has been reconfigured with the appropriate permissions and text and voice channels.\n'])
else:
result = ''.join([result,f'A channel category with the appropriate text and voice channels has been created.\n'])
result = ''.join(['```',result,f'```\n{gm.mention} {r.mention} {t.mention}'])
result = ''.join(['```',result,f'```\n{gm.mention} | {r.mention} | {t.mention}'])
output = f'```Hello {gm.display_name}! Your game channels for `{game_title}` have been created.\nYou can ping your players or edit the game settings by interacting with the game role through the Bot commands. Have fun!```\n'
output = ''.join([output,f'```Game Title: {game_title}\n'])
output = ''.join([output,f'GM: {gm.display_name}\n'])
@ -280,7 +280,7 @@ class GameSetup(commands.Cog, name='Game Setup'):
if str(guildStr) not in categories: categories[guildStr] = {}
gms[guildStr][str(gm.id)].append(r.id)
if guildStr not in categories: categories[guildStr] = {}
categores[guildStr][str(c.id)] = r.id
categories[guildStr][str(c.id)] = r.id
yaml_dump(data,dataFile)
yaml_dump(lookup,lookupFile)
yaml_dump(gms,gmFile)

View File

@ -59,8 +59,8 @@ class PlayerCommands(commands.Cog, name='Player Commands'):
if rStr not in lookup[guildStr]:
await ctx.send(f'```Error: This is not a valid game role. Please mention a role that is associated with a game.```',hidden=True)
return
if not (set(ctx.author.roles) & set([ctx.guild.get_role(x) for x in conf[guildStr]['roles']['admin']]) or ctx.author == ctx.guild.owner):
if not set(ctx.author.roles) & set([ctx.guild.get_role(int(x)) for x in gms[guildStr] if gms[guildStr][x]]):
if not (set(ctx.author.roles) & set([ctx.guild.get_role(x) for x in conf[str(ctx.guild.id)]['roles']['admin']]) or ctx.author == ctx.guild.owner):
if not set(ctx.author.roles) & set([ctx.guild.get_role(int(x)) for x in gms[str(ctx.guild.id)] if gms[str(ctx.guild.id)][x]]):
await ctx.send(f'```Error: You are not authorised to issue this command. The command may only be issued by an administrator or by a GM.```',hidden=True)
return
if ctx.author.id != lookup[guildStr][rStr]['gm']:
@ -70,11 +70,11 @@ class PlayerCommands(commands.Cog, name='Player Commands'):
await ctx.send(f'```Error: Player `{player.display_name}` is already in the game {lookup[guildStr][rStr]["game_title"]}.```',hidden=True)
return
await player.add_roles(game, reason=f'`/player add` command issued by {ctx.author.display_name}`.')
t = lookup[rStr]['time']
t = lookup[guildStr][rStr]['time']
if type(data[guildStr][t][rStr]['current_players']) is not int: data[guildStr][t][rStr]['current_players'] = 1
else: data[guildStr][t][rStr]['current_players'] += 1
hm = lookup[rStr]['header_message']
tc = discord.utils.find(lambda x: x.id == lookup[rStr]['text_message'],ctx.guild.channels)
hm = data[guildStr][t][rStr]['header_message']
tc = discord.utils.find(lambda x: x.id == lookup[guildStr][rStr]['text_channel'],ctx.guild.channels)
if tc is not None:
p = await tc.pins()
if p:
@ -133,24 +133,24 @@ class PlayerCommands(commands.Cog, name='Player Commands'):
if str(ctx.channel.category.id) not in categories[guildStr]:
await ctx.send(f'```Error: This command can only be issued in a text channel associated with a game.```', hidden=True)
return
game = categories[guildStr][str(ctx.channel.category.id)]
game = discord.utils.find(lambda x: x.id == categories[guildStr][str(ctx.channel.category.id)], ctx.guild.roles)
rStr = str(game.id)
if game not in player.roles:
await ctx.send(f'```Error: Player `{player.display_name}` is not in the game {lookup[guildStr][rStr]["game_title"]}.```',hidden=True)
return
if not (set(ctx.author.roles) & set([ctx.guild.get_role(x) for x in conf[guildStr]['roles']['admin']]) or ctx.author == ctx.guild.owner):
if not set(ctx.author.roles) & set([ctx.guild.get_role(int(x)) for x in gms[guildStr] if gms[guildStr][x]]):
if not (set(ctx.author.roles) & set([ctx.guild.get_role(x) for x in conf[str(ctx.guild.id)]['roles']['admin']]) or ctx.author == ctx.guild.owner):
if not set(ctx.author.roles) & set([ctx.guild.get_role(int(x)) for x in gms[str(ctx.guild.id)] if gms[str(ctx.guild.id)][x]]):
await ctx.send(f'```Error: You are not authorised to issue this command. The command may only be issued by an administrator or by a GM.```',hidden=True)
return
if ctx.author.id != lookup[guildStr][rStr]['gm']:
await ctx.send(f'```Error: You are not authorised to issue this command. A player may only be added to a game by the GM or by an administrator.```',hidden=True)
return
await player.remove_roles(game, reason=f'`/player remove` command issued by {ctx.author.display_name}`.')
t = lookup[rStr]['time']
if type(data[guildStr][t][rStr]['current_players']) <= 1: data[guildStr][t][rStr]['current_players'] = None
t = lookup[guildStr][rStr]['time']
if data[guildStr][t][rStr]['current_players'] <= 1: data[guildStr][t][rStr]['current_players'] = None
else: data[guildStr][t][rStr]['current_players'] -= 1
hm = lookup[rStr]['header_message']
tc = discord.utils.find(lambda x: x.id == lookup[rStr]['text_message'],ctx.guild.channels)
hm = data[guildStr][t][rStr]['header_message']
tc = discord.utils.find(lambda x: x.id == lookup[guildStr][rStr]['text_channel'],ctx.guild.channels)
if tc is not None:
p = await tc.pins()
if p:
@ -206,11 +206,11 @@ class PlayerCommands(commands.Cog, name='Player Commands'):
await ctx.send(f'```Error: Player `{player.display_name}` is not in the game {lookup[guildStr][rStr]["game_title"]}.```',hidden=True)
return
await player.remove_roles(game, reason=f'`/player leave` command issued by {ctx.author.display_name}`.')
t = lookup[rStr]['time']
if type(data[guildStr][t][rStr]['current_players']) <= 1: data[guildStr][t][rStr]['current_players'] = None
t = lookup[guildStr][rStr]['time']
if data[guildStr][t][rStr]['current_players'] <= 1: data[guildStr][t][rStr]['current_players'] = None
else: data[guildStr][t][rStr]['current_players'] -= 1
hm = lookup[rStr]['header_message']
tc = discord.utils.find(lambda x: x.id == lookup[rStr]['text_message'],ctx.guild.channels)
hm = data[guildStr][t][rStr]['header_message']
tc = discord.utils.find(lambda x: x.id == lookup[guildStr][rStr]['text_channel'],ctx.guild.channels)
if tc is not None:
p = await tc.pins()
if p:

View File

@ -1,2 +1,3 @@
'864651943820525609':
'866788661026488352': 866788659839238164
'867516972496060446': 867516971017175070

View File

@ -12,3 +12,15 @@
role: 866788659839238164
system: null
text_channel: 866788663194812446
'867516971017175070':
category: 867516972496060446
current_players: 1
game_title: Masks
gm: 493694762210033664
header_message: 867517905620303894
max_players: 5
min_players: null
platform: null
role: 867516971017175070
system: null
text_channel: 867516974212055060

View File

@ -1,4 +1,5 @@
'864651943820525609':
'493694762210033664':
- 866788659839238164
- 867516971017175070
'864649599671205914': []

View File

@ -5,3 +5,9 @@
gm: 493694762210033664
text_channel: 866788663194812446
time: suneve
'867516971017175070':
category: 867516972496060446
game_title: Masks
gm: 493694762210033664
text_channel: 867516974212055060
time: suneve