IceFire
IceFire

Reputation: 33

Discord.py How to tranform a str to a specific type from discord.py

I'm trying to set the permission of the server, using that code a wait ctx.guild.edit(verification_level=line), but I get that error verification_level field must be of type VerificationLevel. I presume the problem is the variable type. How can I transform any str to a specific type used by Discord.py? Thank you for any help.

Upvotes: 0

Views: 85

Answers (1)

Patrick Haugh
Patrick Haugh

Reputation: 61042

discord.py Enums implement __getitem__, and attempt to lookup the supplied key in their internal map. You can do

await ctx.guild.edit(verification_level=VerificationLevel[line])

Upvotes: 1

Related Questions