#I have to tag my bot for it to hear my messages.
1 messages · Page 1 of 1 (latest)
./tag msgcnt
Why is some information about my messages from MessageCreateEvent unavailable?
You may have not enabled the Message Content Intent. This had been a thing for bots from August 31st, 2022 onward. For more info, refer to https://support-dev.discord.com/hc/en-us/articles/4404772028055
Firstly, go to your discord developer portal. In your bot application, in the bot section, tick this to be on. (check the attached screenshot: https://i.imgur.com/8Ps9Boi.png)
Secondly, in your bot's code, add the highlighted lines:
[2;31mbot[0m [2;33m=[0m [2;36m[4;36mhikari[0m[2;36m[0m[4;2m.[0m[2;34m[4;34mGatewayBot[0m[2;34m[0m[2;33m( [2;30m# or [1;30m[4;30mlightbulb[0m[1;30m[0m[2;30m[1;30m[4;30m.[0m[1;30m[0m[2;30m[1;30m[4;30mBotApp[0m[1;30m[0m[2;30m[0m[2;33m[0m
[2;32m"your token"[0m,
[2;35m[2;40mintents[0m[2;35m[0m[2;33m[2;40m=[0m[2;33m[0m[2;36m[2;40mhikari[0m[2;36m[0m[2;40m.[0m[2;34m[2;40mIntents[0m[2;34m[0m[2;40m.[0m[2;34m[2;40mALL_UNPRIVILEGED[0m[2;34m[0m[2;40m | [0m[2;36m[2;40mhikari[0m[2;36m[0m[2;40m.[0m[2;34m[2;40mIntents[0m[2;34m[0m[2;40m.[0m[2;34m[2;40mMESSAGE_CONTENT[0m[2;34m[0m [2;30m# [1;30mAdd this line[0m[2;30m[0m
[2;33m)[0m
You should now receive all information about such messages. :)
Note: You will still receive this information for messages in which the bot is pinged and for any message in DMs, regardless of the intent.
it is on
Your result suggests otherwise
Checklist:
- Do you have the intent in the bot constructor?
- Is it enabled for the bot in the portal?
- Did you rerun the bot after doing the previous two?
what is an intent in the bot constructor
@bot.listen(hikari.GuildMessageCreateEvent)
async def messaged(event):
print(event.content)```
this is what
my script is
The tag I sent tells you what intent you need to add and where
Show us your (tokenless) bot constructor
The part of the code that constructs the bot object
oh
import lightbulb
import hikari
import socket
bot = lightbulb.BotApp(
token="i removed my token just for this",
default_enabled_guilds = (1078358379480752228)
)
@bot.listen(hikari.GuildMessageCreateEvent)
async def messaged(event):
print(event.content)
if event.content == "@woeful ibex Hello":
await bot.rest.create_message(event.channel_id, "Hello, how are you? How may I help you?")
@bot.listen(hikari.StartedEvent)
async def on_started(event):
print("bot was summoned")
@bot.command
@lightbulb.command("hello", "returns a hello")
@lightbulb.implements(lightbulb.SlashCommand)
async def ping(ctx):
await ctx.respond("hi :D")
bot.run()
I mean, I told you by now a few times to read the tag, you haven't done all that the tag tells you to do. Your code right now is never telling Discord what intents it wants
sorry im a begginer
You need to fill in the intents= thing
i dont know what a tag is
This tag
so i add
this exact line
intents=hikari.Intents.ALL_UNPRIVILEGED | hikari.Intents.MESSAGE_CONTENT
@bot.listen(hikari.GuildMessageCreateEvent)
async def messaged(event):
print(event.content)
if event.content == "Hello":
await bot.rest.create_message(event.channel_id, "Hello, how are you? How may I help you?")
else:
await bot.rest.create_message(event.channel_id, "i didnt understand")
@bot.listen(hikari.StartedEvent)
async def on_started(event):
print("bot was summoned")```
the bot says
i didnt understand
a millio ntimes and doesnt stop
You're never checking if the message sent is from a bot or a user
it worked
So it triggers itself
event.is_human or event.is_bot
so i write
else:
if event.is_human:
await bot.rest.create_message(event.channel_id, "i didnt understand")
You could, yes
It would probably be better to do a check first thing in the function
still
its
repeating itself
Traceback (most recent call last):
File "C:\Users\user\OneDrive\Bureau\Bot\bot.py", line 18, in messaged
await bot.rest.create_message(event.channel_id, "i didnt understand")
File "C:\Users\user\OneDrive\Bureau\Bot\env\Lib\site-packages\hikari\impl\rest.py", line 1513, in create_message
response = await self._request(route, json=body)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\OneDrive\Bureau\Bot\env\Lib\site-packages\hikari\impl\rest.py", line 737, in _request
if not self._close_event.is_set():
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'is_set'
@sterile star ?
Never seen that error, so you'll have to wait for dav probably
whos dav
davfsa
@dusky dirge send full logs
thats the full log