#๐ ๐ server messages in terminal not working
36 messages ยท Page 1 of 1 (latest)
@unreal tendon
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.
it should display messages in terminal
and respond with hi there
did you get any errors?
you arent printing anything anywhere
so nothings gonna show up in the terminal
Your on_message is outside the class. Indent it to be inside the class
!indent indent in python is used to show what code is inside what block
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
From personal experience i've found that using default intents doesn't work
not sure if this will fix it but try replacing your intents with this
intents = discord.Intents.all()
Then the error will be different, one step at a time - current error is indentation (bot class doesn't contain on_message)
Then OP will have problems with message intents
using Intents.default doesn't raise errors
usually it just runs but doesn't execute other code
I may be wrong though, this is all from what I've personally dealt with
And as I said, one error at the time - intents won't help now because the function is literally outside the class. Which is part of python basics that are important to understand. Only after we cover that, we can get to explaining the discord.py-specific problem with intents
Oh my fault then
even github ai changed it and its still not working
i dont know whats wrong with it, i tried ai, youtube tutorial google
nothing knows whats wrong
Did you read what I wrote? The function is literally outside the class. Indent it - select whole on_message with all the lines inside it and hit tab once
!indent and read this, it's part of important python basics which you need to understand
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
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.
๐ server messages in terminal not working
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.