Im using the following code to get a user thats in the server however it always returns a value of none. The bot has admin perms and we are spelling the users username correctly each time. I'm not including the numbers at the end even though I have tried that. Please can someone show me where I'm going wrong. Thanks
@client.command(name="getuser" ,pass_context=True, no_pm=True)
@commands.guild_only()
async def get_user(ctx):
msg = ctx.message
server = msg.guild
await ctx.send(f"The @ of the user")
def getUsername(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
Key = await client.wait_for("message", check=getUsername)
user_name = ctx.guild.get_member_named(name=str(Key.content))
if not user_name:
try:
user_name = ctx.guild.get_member(int(Key.content))
await ctx.send(f"Result: " + str(user_name))
except:
print("User Not Found")
if not user_name:
try:
user_name = self.bot.get_user(int(Key.content))
await ctx.send(f"Result: " + str(user_name))
except:
print("User Not Found")
if not user_name:
await ctx.send(f'Could not find user.')
print(f"Result: " + str(user_name))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…