question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello, I’m trying to experiment with some sort of XP system with a bot, where members will gain an amount of XP at random for every message they send, and for testing purposes, I’m trying to get it to tell me the amount of XP that is generated. Here’s my code:

@bot.event
async def on_message(message):
    xpGain = random.randint(0,3)
    print(xpGain)
    await bot.say(message.channel,xpGain)

I’ve tried adding await bot.process_commands(message) to the end of my function which is the only possible remedy I found online, but regardless I still receive the same error message:

TypeError: send_message() takes from 2 to 3 positional arguments but 4 were given

I can’t quite understand it because from what I can see, I’m only giving 2 arguments, message.channel and xpGain, so any help would be greatly appreciated 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
NCPlayzcommented, Apr 17, 2018

You cannot use Bot.say in events, instead use Client.send_message, also if you ran it, it would go on a loop, so you might want to fix that, if that’s not what you want.

1reaction
paradoorcommented, Apr 17, 2018

See this. You shouldn’t be using bot.say outside of commands. Also, in future, these types of questions can be asked at the official Discord server: https://discord.gg/r3sSKJJ

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Bot' object has no attribute 'say' #2260 - Rapptz/discord.py
i just maked the @bot.command() async def ping(ctx): await bot.say('Pong!') but it's don't working...
Read more >
Discord Bot Troubleshooting - Scryfall
Information about common issues with the Scryfall Discord bot. ... have not restricted the bot's ability to see messages and speak in the...
Read more >
Troubleshoot bot configuration issues - Bot Service
A bot can generate different types of errors, such as not being able to respond, throwing errors, or working in one channel but...
Read more >
Meta's AI Chatbot Repeats Election and Anti-Semitic ...
Meta acknowledges that its chatbot may say offensive things, as it's still an experiment under development. The bot's stated beliefs are also ...
Read more >
What Are Spam Bots and Why They're an Issue in Elon Musk's ...
Bots can tweet at people, share tweets, follow and be followed by other people. And there are good bots and bad.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found