#edit() message
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)`