Skip to content

Commit

Permalink
fixed #47
Browse files Browse the repository at this point in the history
  • Loading branch information
s0lst1ce committed Nov 30, 2019
1 parent ce620ec commit 6686cea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
20 changes: 15 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ def is_valid(self, lang):
async def run(self, ctx):
try:
#LANGUAGE CONFIG
print("conf")
good = False
while not good:
lang = await self.get_answer(ctx, f"I'm an international robot and tend to opperate in many places. This also means that I speak many language! The list of supported languages can be found on my website {WEBSITE}. So which do you want to speak with?")
lang = await self.get_answer(ctx, f"I'm an international robot and tend to opperate in many places. This also means that I speak many language! The list of supported languages can be found on my website {WEBSITE}. So which do you want to speak with? Languages are expressed in their 2 letter code.")
if not self.is_valid(lang.content):
continue
good = True
Expand All @@ -54,7 +53,7 @@ async def run(self, ctx):
conf["lang"] = lang.content

#ROLE CONFIG
await self.config_channel.send("Role setup is **mendatory** for the bot to work correctly. Otherwise no one will be able to use administration commands.")
await self.config_channel.send("Role setup is **mandatory** for the bot to work correctly. Otherwise no one will be able to use administration commands.")
await self.config_channel.send("**\nStarting role configuration**\nThis bot uses two level of clearance for its commands.\nThe first one is the **manager** level of clearance. Everyone with a role with this clearance can use commands related to server management. This includes but is not limited to message management and issuing warnings.\nThe second level of clearance is **admin**. Anyone who has a role with this level of clearance can use all commands but the ones related to the bot configuration. This is reserved to the server owner. All roles with this level of clearance inherit **manager** clearance as well.")

new_roles = []
Expand All @@ -63,7 +62,15 @@ async def run(self, ctx):
while retry:
new_role = []
#asking the owner which roles he wants to give clearance to
roles = await self.get_answer(ctx, f"List all the roles you want to be given the **{role_lvl}** level of clearance.", filters=["roles"])
pre_roles = await self.get_answer(ctx, f"List all the roles you want to be given the **{role_lvl}** level of clearance.")

#converting to Role obj
roles = []
for role in pre_roles.content.split(" "):
try:
roles.append(await discord.ext.commands.RoleConverter().convert(ctx, role))
except:
continue

#making sure at least a role was selected
if len(roles)==0:
Expand All @@ -73,7 +80,7 @@ async def run(self, ctx):
#building role string
roles_str = ""
for role in roles:
roles_str += f" {role.mention}"
roles_str += f" {role.name}"

#asking for confirmation
confirmed = await self.get_yn(ctx, f"You are about to give{roles_str} roles the **{role_lvl}** level of clearance. Do you confirm this ?")
Expand Down Expand Up @@ -133,6 +140,9 @@ async def make_cfg_chan(self, ctx_or_guild):
with open(os.path.join(CONFIG_FOLDER, str(g.id)+".json"), "w") as file:
json.dump(DEFAULT_SERVER_FILE, file)

with open(os.path.join(SLAPPING_FOLDER, str(g.id)+".json"), "w") as file:
json.dump(DEFAULT_SLAPPED_FILE, file)

return self.config_channels[g.id]


Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
ERR_UNEXCPECTED = ("Unexcpected error", "An unexcpected error occured. Please report a bug in {} or contact an admin of your server.")
ERR_NOT_ENOUGH_ARG = ("Not enough arguments", "This command requires additional arguments. See `::help <command>` to get more information on the command's usage")
ERR_UNSUFFICIENT_PRIVILEGE = ("Unsufficient privileges", "You don't have the permissions to do this...")
ERR_NOT_SETUP = ("Server not setup", "This server hasn't been configured. If you're the owner of the server you can initialize the bot by doing `::cfg init` in any channel. You won't be able to use the bot before that.")
ERR_NOT_SETUP = ("Server not setup", "This server hasn't been configured. If you're the owner of the server you can initialize the bot by doing `::init` in any channel. You won't be able to use the bot before that.")
ERR_CANT_SAVE = ("Couldn't save configuration", "Couldn't save settings to JSON configuration file.")
ERR_MISFORMED = ("Misformed command", "The command was malformed. See `::help <command>` to get more information on the command's usage")
ERR_TOO_MANY_ARGS = ("Too many arguments", "This command requires less arguments. See `::help <command>` to get more information on the command's usage.")
Expand Down
4 changes: 1 addition & 3 deletions utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def check_condition(ctx):

def was_init(ctx):
'''same as the previous function except this one isn't a decorator. Mainly used for listenners'''
if f"{ctx.guild.id}.json" in os.listdir(CONFIG_FOLDER):
return True
return False
return f"{ctx.guild.id}.json" in os.listdir(CONFIG_FOLDER)

def has_auth(clearance, *args):
'''checks whether the user invoking the command has the specified clearance level of clearance for the server the command is being ran on'''
Expand Down

0 comments on commit 6686cea

Please sign in to comment.