gml13107
gml13107

Reputation: 1

How to solve the discord chatbot didnt reply message

This is my python code for the discord chatbot that I want to create:

import discord
import os
from dotenv import load_dotenv
from neuralintents import GenericAssistant

intents = discord.Intents.default()
intents.message_content = True

client = discord.Client(intents=intents)

chatbot = GenericAssistant('intents.json')
chatbot.train_model()
chatbot.save_model()

load_dotenv()
TOKEN = os.getenv('TOKEN")

@client.event
async def on_ready():
    print(f'We have logged in as {client.user}')

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    if message.content.startswith("!"):
        response = chatbot.request(message.content[2:])
        await message.channel.send(response)

client.run(TOKEN)

And when I run the code it will occur these errors:

ERROR    discord.client Ignoring exception in on_message
Traceback (most recent call last):
  File "anaconda3\lib\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "chatbot.py", line 27, in on_message
    await message.channel.send(responses)
  File "anaconda3\lib\site-packages\discord\abc.py", line 1538, in send
    data = await state.http.send_message(channel.id, params=params)
  File "anaconda3\lib\site-packages\discord\http.py", line 744, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

How can I do to solve these error?

The output should be like: i: !hi bot: hello

Upvotes: 0

Views: 147

Answers (1)

Anonymous Guy
Anonymous Guy

Reputation: 307

response is an empty string. It then tries to send an empty string, yeilding the error.

Edit: It seems you might want to look up discord.py docs instead of using an alpha third party library which provides nothing of value as of now.

Upvotes: 1

Related Questions