#I have to tag my bot for it to hear my messages.

1 messages · Page 1 of 1 (latest)

dusky dirge
#

When I write a message my bot should print the message, but if i dont tag my bot like @bot Hello then it will print None. What can I do?

sterile star
#

./tag msgcnt

median remnantBOT
#

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:

bot = hikari.GatewayBot( # or lightbulb.BotApp
    "your token",
    intents=hikari.Intents.ALL_UNPRIVILEGED | hikari.Intents.MESSAGE_CONTENT # Add this line
)

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.

dusky dirge
#

it is on

sterile star
#

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?
dusky dirge
#

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

sterile star
#

The tag I sent tells you what intent you need to add and where

dusky dirge
#

i did everything

#

re ran the bot

#

re invited

sterile star
#

Show us your (tokenless) bot constructor

dusky dirge
#

i turned on these intents

#

what is a bot contructor

sterile star
dusky dirge
dusky dirge
#
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()
sterile star
#

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

dusky dirge
#

sorry im a begginer

sterile star
#

You need to fill in the intents= thing

dusky dirge
#

i dont know what a tag is

dusky dirge
#

so i add

#

this exact line

#

intents=hikari.Intents.ALL_UNPRIVILEGED | hikari.Intents.MESSAGE_CONTENT

sterile star
#

Yes

#

Once you've done that, show your constructor again

dusky dirge
#
@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

sterile star
#

You're never checking if the message sent is from a bot or a user

dusky dirge
sterile star
#

So it triggers itself

dusky dirge
#

oh

#

how can i fix that

sterile star
#

event.is_human or event.is_bot

dusky dirge
#

so i write

#
else:
  if event.is_human:
    await bot.rest.create_message(event.channel_id, "i         didnt understand")
sterile star
#

You could, yes

#

It would probably be better to do a check first thing in the function

dusky dirge
#

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 ?

sterile star
#

Never seen that error, so you'll have to wait for dav probably

dusky dirge
#

whos dav

sterile star
#

davfsa

lost estuary
#

@dusky dirge send full logs

dusky dirge
lost estuary
#

Not traceback

#

Logs

#

There should be a bunch of red things above that