Browse Source

Fix issue related to missing config for servers + add error handling to ;sa (#15)

* Fix issue related to missing config for servers

* Add error handling to ;sa for role which doesn't exist
tags/v2.0.0
Vallerie 6 years ago
parent
commit
2765f06a12
2 changed files with 21 additions and 9 deletions
  1. +6
    -0
      main.py
  2. +15
    -9
      roxbot/settings/settings.py

+ 6
- 0
main.py View File

@@ -94,6 +94,12 @@ async def on_ready():
print("Servers I am currently in:")
for server in bot.guilds:
print(server)
# this is so if we're added to a server while we're offline we deal with it
try:
gs.get(server)
except KeyError:
print("Server not found in servers.json - adding example config")
gs.add_guild(server)
print("")



+ 15
- 9
roxbot/settings/settings.py View File

@@ -367,16 +367,22 @@ class Settings:
self_assign["enabled"] = 0
await ctx.send("'self_assign' was disabled :cry:")
elif selection == "addrole":
if role.id in self_assign["roles"]:
return await ctx.send("{} is already a self-assignable role.".format(role.name))
self_assign["roles"].append(role.id)
await ctx.send('Role "{}" added'.format(str(role)))
try:
if role.id in self_assign["roles"]:
return await ctx.send("{} is already a self-assignable role.".format(role.name))
self_assign["roles"].append(role.id)
await ctx.send('Role "{}" added'.format(str(role)))
except AttributeError:
return await ctx.send("Role param incorrect. Check you spelt it correctly")
elif selection == "removerole":
if role.id in self_assign["roles"]:
self_assign["roles"].remove(role.id)
await ctx.send('"{}" has been removed from the self-assignable roles.'.format(str(role)))
else:
return await ctx.send("That role was not in the list.")
try:
if role.id in self_assign["roles"]:
self_assign["roles"].remove(role.id)
await ctx.send('"{}" has been removed from the self-assignable roles.'.format(str(role)))
else:
return await ctx.send("That role was not in the list.")
except AttributeError:
return await ctx.send("Role param incorrect. Check you spelt it correctly")
else:
return await ctx.send("No valid option given.")
return self.guild_settings.update(self_assign, "self_assign")

Loading…
Cancel
Save