Killogee
Killogee

Reputation: 53

no response in discord

Hey so when I type $opgg or $ftgopgg it will not come up with anything on the following

@bot.event
async def on_message(message):
  if message.content('$opgg'): 
    response = 'Spend me the names'
    await message.channel.send(response)
    def check(m):
      return m.author.id == message.author.id


    
    opgg = await bot.wait_for('message')
    await message.channel.send(f'https://oce.op.gg/multi/query={opgg.content.replace(" ", "%20")}')
    print("done")

@bot.event
async def on_message(message):
  if message.content == '$ftgopgg': 
    teamopgg = "https://oce.op.gg/multi/query=Disco Inferno, spranze, killogee, blank76, reeks"
    
    
    await message.send(teamopgg.replace(" ", "%20"))
    
    print("Tdone")

it was working like an hour ago but I could not use both commands, I don't know if I've gotten code work or if there is a mistake

Upvotes: 1

Views: 197

Answers (3)

Killogee
Killogee

Reputation: 53

Simple fix all i had to do was remove the lower @bot.event and async def on_message(message)

new code:

@bot.event
async def on_message(message):
  if message.content('$opgg'): 
    response = 'Spend me the names'
    await message.channel.send(response)
    def check(m):
      return m.author.id == message.author.id


    
    opgg = await bot.wait_for('message')
    await message.channel.send(f'https://oce.op.gg/multi/query={opgg.content.replace(" ", "%20")}')
    print("done")

 if message.content == '$ftgopgg': 
    teamopgg = "https://oce.op.gg/multi/query=Disco Inferno, spranze, killogee, blank76, reeks"
    
    
    await message.send(teamopgg.replace(" ", "%20"))
    
    print("Tdone")

Upvotes: 0

šeki
šeki

Reputation: 153

If you want to use bot.command() and on_message event at the same time, you can use :

@bot.listen()
async def on_message(message):

instead of:

@bot.event
async def on_message(message):

Upvotes: 0

Ratery
Ratery

Reputation: 2917

You have 2 on_message events but discord.py supports only one.

If you are trying to create commands for your bot I recommend use @client.command() decorator instead of listening on_message event.

Something like:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="$", intents=discord.Intents.all())

@bot.command()
async def opgg(ctx):
    response = "Spend me the names"
    await message.channel.send(response)
    def check(m):
      return m.author.id == message.author.id

@bot.command()
async def ftgopgg(ctx):
    teamopgg = "https://oce.op.gg/multi/query=Disco Inferno, spranze, killogee, blank76, reeks"
    await message.send(teamopgg.replace(" ", "%20"))
    print("Tdone")

bot.run("TOKEN")

Upvotes: 2

Related Questions