I've looked up other issues people had but I cannot figure out why I'm having this issue. I have no experience in coding, and I am just watching a step by step video on creating a bot for my discord server. I have posted a screen shot of the code and the error message I got.enter image description here
Asked
Active
Viewed 8 times
0
-
Use `discord.Client` (notice the uppercase C) instead of `discord.client`. – mtraceur Sep 15 '22 at 02:56
-
Here's how I figured it out: first, I know that "module object is not callable" is an error that you get when you try to "call" a module object ("call" is a way of saying "run" or "execute" for things like functions); the error text refers to the fourth line of your code: `discord.client()` is trying to "call"/run/execute the thing that the name `discord.client` refers to, as if it was a function, but it turns out that thing is a module. So that's how we know what the error is telling us. – mtraceur Sep 15 '22 at 03:03
-
So based on that, we know that a tutorial probably told you to call something that looks *similar to* `discord.client` but *not exactly* that. Likely beginner mistakes are using `discord.client` instead of `discord.Client` or `discord.client.Client` or `discord.client.client`. So then I just have to figure out what the right thing is. So then I throw some relevant keywords into search: "Python discord client api discord.client". Key word are "Python" "discord", and "api". "Client" helps narrow down. "discord.client" specifically makes it more likely that we find exactly what you were using. – mtraceur Sep 15 '22 at 03:10
-
Somewhere on the first page of search results I found [this API documentation page](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client). ("API" and "documentation" are pretty helpful words to search when trying to program or script something - "API" is basically what we call the parts of other people's code that you're supposed to use, and we software people normally use the word "documentation" for all descriptions and usage instructions for our code.) That seemed to be the only Python library for Discord in the first search results, so it seems likely that's the one you used. – mtraceur Sep 15 '22 at 03:19
-
Tip #1 for asking questions in the future on here: try to give all details needed to retrace your steps: in software, when in doubt, provide all the details, and in this case, at least link the tutorial you were following (this helps us figure out what you did or what might have gone wrong). But ideally, as yourself: could a complete stranger who knows nothing about what I'm doing do *exactly* what I did? Try retracing your own steps using the information you gave. That way you'd notice things like "oh I never told them the name of the Python package for Discord that I installed". – mtraceur Sep 15 '22 at 03:29
-
Tip #2 for asking questions: try to first search for, and *understand*, the error message text. This helps you ask a question that is less likely to be closed as a duplicate, and more likely to get answers that answer what you actually need answered. For example, if you said "I searched for 'module object is not callable', I just don't understand why it thinks `discord.client` is a module but the tutorial says to call it", then you'd be more likely to get answers like "oh, it's case sensitive, you got the capitalization wrong, and there happened to be a module with the lowercase name". – mtraceur Sep 15 '22 at 03:41
-
Notably, your question got closed as "duplicate", but that other question only does a great job of answering *the first half* of your problem - the "what does this error mean?" half. But the "but *why* is `discord.client` a module and not callable? the tutorial said to call it?" was very unlikely to get answered. – mtraceur Sep 15 '22 at 03:53