DeasileX

How To Fix Error Discord.client Ignoring Exception In On_Message?

How To Fix Error Discord.client Ignoring Exception In on_message

Are you trying to make a Discord bot, and you come across the ignoring exception in on_message error? Well, In this article, let us see how to fix the error Discord.client ignoring exception in on_message.

You can make your own Discord bot in the programming language of your choice if you have the necessary expertise. Discord provides a developer API where you can register a new application with a token to achieve this.

To fix error Discord.client ignoring exception in on_message, use “message.channel.send” if send message throws an error, receive a response to the correct message by passing the right argument and use the up-to-date version of the Discord library.

Continue reading further to understand in detail how to fix the error Discord.client ignoring exception in on_message and what are the available fixes.

How To Fix Error Discord.Client Ignoring Exception In On_Message?

Use the most recent version of the Discord library to obtain a response to the proper message and fix the error Discord.client ignoring exception in on_ message by using “message.channel.send” if sending message results in an error.

While trying to create a bot using a programming language like python, we come across errors while executing the program and we must learn to handle the errors that our commands throw us at. When an invalid request is made, the Discord API will throw API Errors, also known as DiscordAPIErrors. Most API errors can be identified using the provided message. By looking at the HTTP method and path utilized, errors can be examined further.

One such commonly occurring error while trying to build the Discord bot is ignoring exception in on_message and many users have raised the question of how to fix error Discord.client ignoring exception in on_message. This error occurs in a scenario when the bot tries to send a DM message to a user but is unable to do so. There are a few causes for this:

  1. The user and the bot share no guild. Often, people attempt to DM the user after kicking or banning them but a bot is being tried to DM.
  2. You are not using the up-to-date version of the Discord library.

When the bot receives a message, the on message() event is triggered. We must ensure that we ignore messages from ourselves because the on message() event is triggered for every message received. A few fixes to get rid of the ignoring exception in on_message are:

Fix 1: Use message.channel.send If Your Send Message Throws The Error

Let us say your code looks like this and throws the error upon executing it.

@client.async_event

async def on_message(message):

    author = message.author

   if message.content.startswith(‘!test’):

        print(‘on_message !test’)

        await test(author, message)

async def test(author, message):

    print(‘in test function’)

    await client.send_message(message.channel, ‘Hi %s, i heard you.’ % author)

client.run(“key”)

How To Fix Error Discord.client Ignoring Exception In on_message - error message

The send message() function can no longer be used with Discord.py. However, this does not exclude us from sending messages. There is another way to transmit messages across the channel.

Implement your code with await message.channel.send(“”)

@client.async_event

async def on_message(message):

    author = message.author

   if message.content.startswith(‘!test’):

        print(‘on_message !test’)

        await test(author, message)

async def test(author, message):

    print(‘in test function’)

    await message.channel.send(F’Hi {author}, I heard you.’)

client.run(“key”)

Now, you would be able to fix error Discord.client ignoring exception in on_message.

Fix 2: Receive The Response To The Correct Message 

Let us say the error occurs when I ask the bot to say @{username} and your source code looks like this:

async def OnMessage(Message): 

if Message.author == Bot.user:

return

if Message.content.startswith(“<@” + str(Bot.user.id) + “>”):

Text = ToText(Message.content)

Find = False

for i in MessageTable:

if i == Text:

Find = True

if Find:

await SendMessage(MessageTable[Message.content], User=Message.author.id)

How To Fix Error Discord.client Ignoring Exception In on_message - error message when bot is asked to say username

You are attempting to retrieve the response to “<@1642212741386> hi,” which your code is unable to handle, rather than “hi,” which is what you requested. 

So, Instead of “await SendMessage(MessageTable[Message.content], User=Message.author.id)” try replacing the code with,

“await SendMessage(MessageTable[Text], User=Message.author.id)

Now, you would be able to fix the error Discord.client ignoring exception in on_message. If the error is still not fixed, check whether you are using the latest version of the Discord library.

Wrapping Up

We have come to the end of the post, and we hope this article has been helpful and has explained to you how to fix the error Discord.client ignoring exception in on_message. For more such informative and interesting articles, check out our website at Deasilex.

Frequently Asked Questions 

Q1. Is Creating Discord Bots Free?

Ans. If not, visit the Discord webpage to create one at no cost. The Discord client is also available for download, and you may use it on a phone or your gaming laptop. To utilize the bot, you must first configure your own server. By taking a few easy steps, you may quickly invite the bot to your server.

Q2. Why Is My Bot Not Working On Discord?

Ans. Ensure that the bot can be shown on the user list. The bot does not have access to your current channel if it is not visible. Try direct messaging the bot for a card like [[Chromanticore]].

Q3. Is Discord Bot Hard To Make?

Ans. Making a Discord bot is a rather easy process. To set everything up, you do need a basic understanding of programming, although the complexity of the code may vary depending on the type of bot you are building.

Q4. Why Is My Discord Bot Token Invalid?

Ans. It’s possible that the link you clicked to change your password has expired if you attempt to reset your password and receive an error stating that your token is “invalid” or asking for it. Passwords are never sent over the Internet for security reasons.

Q5. How Do I Fix Discord Error?

Delete the Discord app’s data
Use compatibility mode when using Discord
Disable the antivirus software
In Safe Mode, install Discord
Reinstall Windows

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top