Skip to content

Commit

Permalink
Added support for multiple-word usernames in commands that use usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Aug 16, 2018
1 parent 6c11629 commit 9cb489f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions plugins/helped.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ async def helped(ctx, *args):
was_message_found = True

else:
if args[0].startswith('<@') and args[0].endswith('>'):
if len(args) == 1 and args[0].startswith('<@') and args[0].endswith('>'):
commended_user = ctx.guild.get_member(int(args[0].strip('<@!>')))
else:
commended_user = ctx.guild.get_member_named(args[0])
commended_user_username = ''
for arg in args:
commended_user_username += arg + ' '
commended_user_username = commended_user_username.strip()
commended_user = ctx.guild.get_member_named(commended_user_username)

async for message in ctx.channel.history(limit=10):
message.content
Expand Down
7 changes: 5 additions & 2 deletions plugins/reddit_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@ async def redditcheck(ctx, *args):
discord_username = str(ctx.author)

else:
if args[0].startswith('<@') and args[0].endswith('>'):
if len(args) == 1 and args[0].startswith('<@') and args[0].endswith('>'):
# If user was mentioned convert his ID to a username and then check if he is a member of the server
raw_discord_username = str(await client.get_user_info(int(args[0].strip('<@!>'))))
else:
# Otherwise autofill user's tag (number) and check if he is a member of the server
raw_discord_username = args[0]
raw_discord_username = ''
for arg in args:
raw_discord_username += arg + ' '
raw_discord_username = raw_discord_username.strip()

discord_username = ctx.message.guild.get_member_named(raw_discord_username)

Expand Down

0 comments on commit 9cb489f

Please sign in to comment.