#๐Ÿ”’ What's wrong with this Bot's code?

25 messages ยท Page 1 of 1 (latest)

hasty masonBOT
#

@craggy pebble

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

drowsy stone
#

discord.Client() needs an 'intents' keyword argument

#

!d discord.Client

hasty masonBOT
#

class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

async with x Asynchronously initialises the client and automatically cleans up.

New in version 2\.0\.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client).
formal imp
#

are u making a discord bot?

craggy pebble
#

yes

#

ok

#

so i have to make a keyword argument?

#

like. !d

#

at the start?

#

thats it?

drowsy stone
#

by keyword argument it means that you are going to pass a named argument into the discord.Client's constructor method

#

i.e. discord.Client(intents=...)

craggy pebble
#

I dont understand ive never made a bot before

#

and what are intents=?

drowsy stone
craggy pebble
#

First, i understand Tkinter n stuff but not discord.

#

I never even touched it.

drowsy stone
#

okay, so if I have a function like this py def func(a, b, c): print(a, b, c) then it has 3 arguments: a, b, and c. When I call my function I am not required to explicitly say the name of the parameter because they have not been marked as 'keyword-only'. However, I can explicitly name the parameters if I wish so func(1, 2, 3) is the same as func(a=1, b=2, c=3). I can even change the order of my keyword arguments: func(c=3, b=2, a=1) is the same as the two examples above.

When I define a function, I am also able to mark certain parameters as being 'keyword-only' i.e. the caller is required to explicitly state the name of the parameter when calling py def func(*, a, b, c): print(a, b, c) Now the only way I can call this function is by running func(a=1, b=2, c=3). The 'intents' parameter for the discord.Client constructor method is like this so you must refer to the parameter name explicitly when you make a new discord.Client object.

I read the documentation for discord.Client and it seems like you have to pass in a discord.Intents object for the 'intents' keyword argument.

craggy pebble
#

That literally just didn't help me in anything, all you just said is stuff i already know even when i told you i did understand how they work just not what to put in the intent thing. Anyways. Goodbye.

hasty masonBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ What's wrong with this Bot's code?