#confused
1 messages · Page 1 of 1 (latest)
Hey! Once your issue is solved, press the button below to close this thread!
In interactions.py, there is a difference between getting or fetching an object.
Getting an object only looks at objects that have been cached, and therefore is a synchronous function. Getting an object can occasionally return None if that object has never been cached before. Here are some use cases:
user: User | None = bot.get_user(123456789)
member: Member | None = guild.get_member(123456789)```
Although interactions.py's cache system is very reliable, you might sometimes want to make sure that None will not be returned. This is were **fetching** an object becomes useful. When fetching an object, interactions.py will first look if that object is cached. If not, it will then request that object from the Discord API asynchronously. Here are some use cases:
```py
user: User = await bot.fetch_user(123456789)
member: Member = await guild.fetch_member(123456789)```
_Note:_ If you want to skip interactions.py checking if the object is first cached, and directly fetch the object from the Discord API, you can use the optional argument `force=True`. This can become very useful for some features that are never passed by the Discord Gateway except when fetching.
Example: `user: User = await bot.fetch_user(123456789, force=True)`
bot = interactions.Client(token)
user = await bot.get_user(578732669194600448)
it just gives the error: AttributeError: 'Client' object has no attribute 'get_user'
you should get user after you start the bot
Show full code
import interactions
bot = interactions.Client(token='mytokenhere')
@bot.event
async def on_ready():
print(f'Logged in as {bot.me.name}')
user = await bot.get_user(578732669194600448)
await user.send("This is a test message from your bot!")
bot.start()```
What version of interactions.py and what version of python are you on?
discord-py-interactions 5.10.0
Python 3.11.4
okay i messed with all the discord packages i have and now everytime i try to run it, it just does nothing nothing loads or happens not sure what is going on
what packages do i need for it to work
only discord.py-interactions?
or do i need more
Installing it should install any other required packages
would other discord packages possibly interfere with it
It shouldn't?
what other packages did you install?
discord-py-slash-command
that is an old version of this library
oh shoot lmao
can you send what comes out of your console when you use pip freeze
Please refer to this link here for reading up on our library's documentation.
welp looks like i was using the old version this whole time
interactions.py v4 is no longer supported. Please upgrade to the latest version and use the migration guide to upgrade your code.
Just in case you can check here how to migrate etc