Skip to content

Remove unnecessary iter() calls #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,23 @@ async def logout(ctx):

@bot.command(pass_context=True)
async def sub(ctx, *args):
"Subtracts any roles mentioned after sub if they exist say all for all possible roles to remove"
member = discord.utils.get(ctx.guild.members, name=ctx.author.name)
for arg in args:
if(arg == "all"):
roles = ctx.guild.roles
iterroles = iter(roles)
next(iterroles)
for role in iterroles:
if role.name == "hackbot 1.1":
break
else:
await member.remove_roles(role)
break
else:
role = discord.utils.get(ctx.guild.roles, name=arg)
await member.remove_roles(role)
await ctx.send('I\'ve removed your requested roles %s!' %ctx.author.name)
"Subtracts any roles mentioned after sub if they exist say all for all possible roles to remove"
member = discord.utils.get(ctx.guild.members, name=ctx.author.name)
for arg in args:
if(arg == "all"):
roles = ctx.guild.roles
for role in roles:
if role.name == "hackbot 1.1":
break
elif role.name == "@everyone":
continue
else:
await member.remove_roles(role)
break
else:
role = discord.utils.get(ctx.guild.roles, name=arg)
await member.remove_roles(role)
await ctx.send('I\'ve removed your requested roles %s!' %ctx.author.name)

"""
@sub.error
Expand All @@ -145,23 +145,23 @@ async def sub_error(error, ctx):

@bot.command(pass_context=True)
async def add(ctx, *args):
"Adds any roles mentioned after add if they exist say all for all roles possible to add"
member = discord.utils.get(ctx.guild.members, name=ctx.author.name)
for arg in args:
if(arg == "all"):
roles = ctx.guild.roles
iterroles = iter(roles)
next(iterroles)
for role in iterroles:
if role.name == "hackbot 1.1":
break
else:
await member.add_roles(role)
break
else:
role = discord.utils.get(ctx.guild.roles, name=arg)
await member.add_roles(role)
await ctx.send('I\'ve added your new roles %s!' %ctx.author.name)
"Adds any roles mentioned after add if they exist say all for all roles possible to add"
member = discord.utils.get(ctx.guild.members, name=ctx.author.name)
for arg in args:
if(arg == "all"):
roles = ctx.guild.roles
for role in roles:
if role.name == "hackbot 1.1":
break
elif role.name == "@everyone":
continue
else:
await member.add_roles(role)
break
else:
role = discord.utils.get(ctx.guild.roles, name=arg)
await member.add_roles(role)
await ctx.send('I\'ve added your new roles %s!' %ctx.author.name)

"""
@add.error
Expand Down