#๐ why the on_message event not working?
53 messages ยท Page 1 of 1 (latest)
@ivory basin
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.
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
You leaked your bot token btw
shit at least i didnt leak my ip port ad pwd
Doesn't message.channel.send need await?
right but the prints dont run either
if message.author == client.user:
return```
make sure the bot doesnt trigger on message
and put a print outside the if statement to see if on_message works in the first place
it never replys starting with . but thx i was trying to find that
there is the one in the else that dont trigger either
remove the else part and put print("sad") outside of the if statement for now
run it again and lmk how it goes
still nothing happens
what is this part
with mcrcon.MCRcon(HOST,PWD,PORT) as server:
it starts an rcon connection to my mc server bc this bot is supposed to send commands to it
yeah ive never used it before, so if on_message isnt working because of it then idk what else it could be
huh i removed it and than the check function runs and it prints ran
i see just now that also didnt run until now
i added the with in the duncs separately and the check runs the bot runs but the on_message dont work
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
i get no errors and 8 is administrator privilage
Are you sure?
In [11]: discord.Intents(8).messages
Out[11]: False
https://discord.com/oauth2/authorize?client_id=122473588945211554&permissions=8&scope=bot i left an error in it so u cant use it but this is the link i use to add the bot
it says premissions=8
that's different to intents
and says that when i specify scope bot premissions Administrator
oh
if you want all the intents then you can do discord.Intents.all()
you also need to make sure you've enabled them in the developer portal
Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
intents is a separate thing in the portal
this?
๐
by any chance do u know how to get all the users currently in a vc?
There's a .members attribute on the VoiceChannel object, and if you know the channel ID you can use get_channel to get the VoiceChannel object https://discordpy.readthedocs.io/en/latest/api.html?highlight=get_channel#discord.Client.get_channel
(method) def get_channel(
id: int,
/
) -> (GuildChannel | Thread | PrivateChannel | None)
it dosent seem to be able to find voice channels
it should, a VoiceChannel is a type of GuildChannel
when i run it i get
Exception has occurred: AttributeError
'NoneType' object has no attribute 'members'
File "/home/opc/python/console.py", line 15, in check
members=bot.get_channel(1226117248154861572).members
File "/home/opc/python/console.py", line 25, in <module>
check(10)
AttributeError: 'NoneType' object has no attribute 'members'
for members=bot.get_channel(1226117248154861572).members
and i am sure the id is correct
1226117248154861572
right click the channel
click copy channel id how could i get an in valid channel with that
!close
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.