isinstance
calls PYL-R1701115 await ctx.channel.send(embed=discord.Embed(color=discord.Color.red(), title=":(\nYour command ran into a problem.", description=f"Sorry {interaction.user.mention}, it looks like I took too long to respond to you! If I didn't do what you wanted in time, please try again."), delete_after=7)
116 return
117
118 if (isinstance(error, commands.MissingRequiredArgument)119 or isinstance(error, PermissionsFailure)
120 or isinstance(error, TransformerError)
121 or isinstance(error, commands.BadArgument)
158 id = invite.guild.id
159 else:
160 id = 123
161 elif isinstance(invite, discord.PartialInviteGuild) or isinstance(invite, discord.PartialInviteChannel):162 id = invite.id
163
164 if id not in whitelist:
You can pass a tuple of types you want to check as the second argument to isinstance
.
If the object matches with any of the types, it will return True
else False
.
It is therefore recommended to merge multiple consecutive isinstance
calls into one. It is clearer and improves readability.
# Instead of
if isinstance(i, int) or isinstance(i, float):
print('A number')
# Do this
if isinstance(i, (int, float)):
print('A number')