#confused

1 messages · Page 1 of 1 (latest)

violet atlas
#

i cant understand the docs because they're just incredibly confusing im trying to figure out how i can fetch a user by their discord id and message them (not from a command or anything)

tough martenBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

tough martenBOT
#

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)`
violet atlas
#

bot = interactions.Client(token)
user = await bot.get_user(578732669194600448)
it just gives the error: AttributeError: 'Client' object has no attribute 'get_user'

kind hedge
violet atlas
#

that’s what i’m doing

#

it’s on the onready event function

kind hedge
#

Show full code

violet atlas
# kind hedge 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()```
rustic cargo
violet atlas
#

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

rustic cargo
#

Installing it should install any other required packages

violet atlas
#

would other discord packages possibly interfere with it

rustic cargo
#

It shouldn't?

kind hedge
violet atlas
#

discord-py-slash-command

kind hedge
violet atlas
#

oh shoot lmao

kind hedge
#

can you send what comes out of your console when you use pip freeze

tough martenBOT
#

Please refer to this link here for reading up on our library's documentation.

violet atlas
#

welp looks like i was using the old version this whole time

tough martenBOT
kind hedge
violet atlas
#

module 'interactions' has no attribute 'Client'

#

nvm