Cómo detener los mensajes repetitivos, y el token es cambiado, pero no se ejecuta.
Hoy comencé a aprender Python y creé un bot de Discord. Tengo algunos problemas:
- Se usó
If message.author ==
en el bloqueon_message
, pero el bot continuó respondiendo a sí mismo. - Después, se creó un nuevo bot con un nuevo token y el código no funcionó.
Busqué mucho en este sitio y en Google. No encontré ninguna solución. Está bien modificar mi código. Todo proviene de internet, así que puede ser un desastre. Por favor, ayúdame.
import discord
import asyncio
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix="!")
@bot.event
async def on_ready():
print('Conectado como Bot: ', bot.user.name)
print('ID del Bot: ', bot.user.id)
print('¡La conexión fue exitosa!')
print('=' * 30)
@client.event
async def on_message(message) :
<pre><code>if on_message.content.startswith('!의뢰'):
msg = on_message.channel.content[3:]
embed = discord.Embed(title = "브리핑", description = msg, color = 0x62c1cc)
embed.set_thumbnail(url="https://i.imgur.com/UDJYlV3.png")
embed.set_footer(text="C0de")
await on_message.channel.send("새로운 의뢰가 들어왔습니다", embed=embed)
await client.process_commands(message)
</code></pre>
client.run("Token de mi bot.")
davy.ai
Solución para Problemas de Bots en Discord
if message.author.bot:
para verificar si el remitente del mensaje es un bot o no. Si es un bot, entonces la función debe retornar sin realizar más procesamiento.Aquí está el código actualizado:
client.run()
en lugar debot.run()
. Asegúrate de usar el nombre de variable correcto al ejecutar el bot.Aquí está el código corregido:
Espero que esto te ayude con tu bot de Discord ¡Buena suerte con tus futuros proyectos en Python!