Is it possible to get someone's user ID who you know their username and discrim, but is not in a mutual server with you?
Thanks.
I don't think so. It makes sense since this can easily be abused. Imagine all the spam bots if bots can see all discord users.
Below are two ways to get user info using discord.py, but note that they cannot be used as you ask.
client.get_user_info can be used to get user info even if you don't share a server, but it takes the unique ID as an argument.
server.get_member_named returns the unique user ID and takes username plus the optional discriminator as input, but requires that you share server/guild with the user to work.
Related
I saw a lot of bots that requires an user mention, fetch through guild members while we type. And I have absolutely NO IDEA in how to let my bot show the users in the required field. No need the be a big code, just an easy and simple way.
#bot.hybrid_command(with_app_command=True)
async def hug(ctx, user):
I want to my discord bot show me a list of user while I'm inputing their nicknames after
"/command-name user:"
By using the search term "discord.py user parameter", there are many resources that work just fine. Here is a different SO post that solves this exact problem.
Discord.py set user id as an argument
Please remember to make an attempt at making the code before posting it to SO.
I am trying to learn to make a telegram bot but I am not sure how to achieve continuous conversations. All I know is how to respond to the individual messages, for example like this -
If a user enters wrong command, for example /jnaddaad
def unknown_response(update: Update, context: CallbackContext):
update.message.reply_text(
"Sorry I can't recognize you , you said '%s'" % update.message.text)
My use-case is simple -
User enters his country using /addcountry command.
After the country, I will as ask what city is he from, and he should be able to answer using /addcity command.
After city, he should be able to enter the addresses(multiple) using /addaddresses
I save everything in a database - username, country, city and addresses.
User can update/delete one or more addresses.
Note:- User should not be directly able to enter city without country, and addresses with city. So the flow should be addcounty -> addcity -> addaddresses. And without the previous steps, user should not be able to access current steps.
I can probably be able to do 1 and 4. I just want a direction on how can I achieve the asked. Do I need to maintain a database with user and current user's username and steps they have performed till now, or is it possible with python-telegram-bot?
That should be achievable with just python-telegram-bot and the ConversationHandler.
The official docs for the ConversationHandler have a good explanation and also (more importantly) four fully working example bots.
I need to get a list of all friends' names and birthdates from facebook to make a program to automatically send out birthday messages, but even after going through the facepy, and facebook documentation I couldn't find anything up to date that works.This is the closest i have gotten, this returns the amount of friends I have.
from facepy import GraphAPI
graph = GraphAPI('user_token')
query = graph.get("me")['name'] # user's name
print(query)
friend_count = graph.get("me/friends")['summary']['total_count'] # user's friend count
print(friend_count)
Getting all friends is not possible anymore, since many years. You can only get friends who authorized your App too, and they need to authorize with the correct permission.
Automatically sending messages would not be possible anyway for other reasons too, there is no API to automatically send messages from user to user, for example.
I found it
GET
https://graph.facebook.com/v13.0/me?fields=friends%7Bbirthday%7D&access_token=
it doesn't get information when in "self" mode
How do I get the user/member object in discord.py with only the Name#Discriminator? I searched now for a few hours and didn't find anything. I know how to get the object using the id, but is there a way to convert Name#Discriminator to the id?
The user may not be in the Server.
A bot can only get a User instance, that it isn't in a server with, from a unique ID.
You can use both discord.utils.get and get_all_members to get a Member using your input though:
member = discord.utils.get(bot.get_all_members(), name='name', discriminator='discriminator')
# discriminator should not contain #
P.S afaik utils.get takes any kwarg that could be an attribute for a class
There's no way to do it if you aren't sure they're in the server. If you are, you can search through the servers' members, but otherwise, it wouldn't make sense. Usernames/Discriminators change all the time, while IDs remain unique, so it would become a huge headache trying to implement that. Try doing what you want by ID, or searching the server.
I'm working on an application that lets registered users create or upload content, and allows anonymous users to view that content and browse registered users' pages to find that content - this is very similar to how a site like Flickr, for example, allows people to browse its users' pages.
To do this, I need a way to identify the user in the anonymous HTTP GET request. A user should be able to type http://myapplication.com/browse/<userid>/<contentid> and get to the right page - should be unique, but mustn't be something like the user's email address, for privacy reasons.
Through Google App Engine, I can get the email address associated with the user, but like I said, I don't want to use that. I can have users of my application pick a unique user name when they register, but I would like to make that optional if at all possible, so that the registration process is as short as possible.
Another option is to generate some random cookie (a GUID?) during the registration process, and use that, I don't see an obvious way of guaranteeing uniqueness of such a cookie without a trip to the database.
Is there a way, given an App Engine user object, of getting a unique identifier for that object that can be used in this way?
I'm looking for a Python solution - I forgot that GAE also supports Java now. Still, I expect the techniques to be similar, regardless of the language.
Your timing is impeccable: Just yesterday, a new release of the SDK came out, with support for unique, permanent user IDs. They meet all the criteria you specified.
I think you should distinguish between two types of users:
1) users that have logged in via Google Accounts or that have already registered on your site with a non-google e-mail address
2) users that opened your site for the first time and are not logged in in any way
For the second case, I can see no other way than to generate some random string (e.g. via uuid.uuid4() or from this user's session cookie key), as an anonymous user does not carry any unique information with himself.
For users that are logged in, however, you already have a unique identifier -- their e-mail address. I agree with your privacy concerns -- you shouldn't use it as an identifier. Instead, how about generating a string that seems random, but is in fact generated from the e-mail address? Hashing functions are perfect for this purpose. Example:
>>> import hashlib
>>> email = 'user#host.com'
>>> salt = 'SomeLongStringThatWillBeAppendedToEachEmail'
>>> key = hashlib.sha1('%s$%s' % (email, salt)).hexdigest()
>>> print key
f6cd3459f9a39c97635c652884b3e328f05be0f7
As hashlib.sha1 is not a random function, but for given data returns always the same result, but it is proven to be practically irreversible, you can safely present the hashed key on the website without compromising user's e-mail address. Also, you can safely assume that no two hashes of distinct e-mails will be the same (they can be, but probability of it happening is very, very small). For more information on hashing functions, consult the Wikipedia entry.
Do you mean session cookies?
Try http://code.google.com/p/gaeutilities/
What DzinX said. The only way to create an opaque key that can be authenticated without a database roundtrip is using encryption or a cryptographic hash.
Give the user a random number and hash it or encrypt it with a private key. You still run the (tiny) risk of collisions, but you can avoid this by touching the database on key creation, changing the random number in case of a collision. Make sure the random number is cryptographic, and add a long server-side random number to prevent chosen plaintext attacks.
You'll end up with a token like the Google Docs key, basically a signature proving the user is authenticated, which can be verified without touching the database.
However, given the pricing of GAE and the speed of bigtable, you're probably better off using a session ID if you really can't use Google's own authentication.