user = discord.utils.get(client.users, name="name", discriminator="0000") comes back with none

103
April 18, 2022, at 02:20 AM

So i want to be able to mention a user when I input there name and discriminator but I cant get it to work as it keeps return none

import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client(token=config.TOKEN, intents=intents)
@bot.event
async def on_message(message):
  if message.content == "$test"
     user = discord.utils.get(client.users, name="killogee", discriminator="0141")
     print(user)

I've also tried:
user = message.guild.get_member_named("Killogee")
but everytime comes back with none

Answer 1

Set out your txt file like this:

user1#8583
user2#0637
user3#9729

Then just use this

f = open('names.txt','r').splitlines() # Opens the text file and turns it into a list
for i in f: # Iterate through that list
    i = i.split('#') # Split the line in two via the hashtag
    user = discord.utils.get(client.users, name=i[0], discriminator=i[1])
    # i[0] is the name, such as user1 and i[1] is the discriminator after the hashtag
    print(user)

It should work, so make sure that your names are correct and up to date

Rent Charter Buses Company
READ ALSO
What is the logic behind this fstring in python?

What is the logic behind this fstring in python?

From this question: Converting an integer to signed 2's complement binary string

121
How to switch to predict mode in Trax after training a model?

How to switch to predict mode in Trax after training a model?

I'm familiarizing myself with the Trax library for building deep learning models and one question that I can't find an answer to is how to switch from "train" mode to "eval" mode after model training is complete

104
Rotate point about another point in degrees python

Rotate point about another point in degrees python

If you had a point (in 2d), how could you rotate that point by degrees around the other point (the origin) in python?

195
Seaborn Lineplot- Displaying Values on top of the markers

Seaborn Lineplot- Displaying Values on top of the markers

We could display a values from dataframe to the graph using the brand new feature of the matplotlib in bar graph

84