Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added difference between get_ commands and fetch_ commands in FAQ #2123

Closed
wants to merge 19 commits into from
Closed
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ Putting both of these pieces of info together, you get the following: ::
activity = discord.Activity(name='my activity', type=discord.ActivityType.watching)
client = discord.Client(activity=activity)

What is the difference between get_ methods and fetch_ methods?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Get" methods retrieve objects or data from the cache (general store of data) and can return ``None`` if not found. "Fetch" methods force an API request and will raise an error if not found. Example: ::

# --- Get example ---
role = member.guild.get_role(id) # Try to get role without an API request through the cache
await member.add_roles(role) # If the role is found, then it adds the role

# --- Fetch example
role = discord.utils.get(await member.guild.fetch_roles(), id=id) # This will obtain the role via an API request

How do I send a message to a specific channel?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down