Bots & AutomatizacionBots de DiscordLección 1 de 7
Crear tu primer bot de Discord
Discord tiene una API potente para crear bots. Puedes hacer bots de moderacion, musica, juegos, utilidades y mas. Empresas usan bots de Discord para soporte al cliente y comunidades.
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!", intents=discord.Intents.default())
@bot.event
async def on_ready():
print(f"Bot conectado como {bot.user}")
@bot.command()
async def hola(ctx):
await ctx.send(f"Hola {ctx.author.name}! 👋")
@bot.command()
async def ping(ctx):
latency = round(bot.latency * 1000)
await ctx.send(f"Pong! 🏓 {latency}ms")
bot.run("TU_TOKEN_AQUI")
Para obtener el token: 1. Ve a discord.com/developers/applications 2. New Application → nombre: MiBot 3. Bot → Add Bot → Copy Token 4. OAuth2 → URL Generator → bot → permissions → Copy URL 5. Pega la URL en el navegador para invitar el bot a tu server
Practica esta lección
Resuelve los ejercicios del curso de Bots & Automatizacion en la app, gratis y con corrección automática.
Empezar a practicar