Discord.py: Returned string not seen as a string?

Created on 14 Jan 2018  路  2Comments  路  Source: Rapptz/discord.py

Not sure if I'm doing this in the best way possible, but...

@bot.command(pass_context=True)
async def test2(ctx, txt):
role = discord.utils.get(ctx.message.server.roles, name="{}".format(txt))
if isinstance(role, six.string_types):
await bot.say(role)
else:
await bot.say("False")

await bot.say(role) successfully sends a string(i.e "Member") by itself (no IF statement), but when I compare it to another string it doesn't work. I ended up setting up the line above to test if it's a string and it comes back as false, so I don't really understand what the issue is.

invalid

Most helpful comment

I'm not entirely sure what you're doing, or what your question is. Role will either be an instance of discord.Role or None, if utils.get cannot find something.

Also, issues are not for general coding help. Use the discord server for that. https://discord.gg/r3sSKJJ

All 2 comments

I'm not entirely sure what you're doing, or what your question is. Role will either be an instance of discord.Role or None, if utils.get cannot find something.

Also, issues are not for general coding help. Use the discord server for that. https://discord.gg/r3sSKJJ

six is for python 2 and 3 support so I don't know why you're using that either considering this library is for Python 3 only.

Anyway this isn't an issue with the library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PicklesJars picture PicklesJars  路  3Comments

ghost picture ghost  路  3Comments

TunaHobby picture TunaHobby  路  3Comments

danshat picture danshat  路  3Comments

AraHaan picture AraHaan  路  3Comments