我是 python 的初学者,我正在创建一个不和谐的机器人,由于显而易见的原因,我在代码中遇到问题,我还想修改所有命令并将它们创建为 ping 命令,即斜线命令,我不不知道我做对了还是错了最好的方法是斜杠命令,但我知道这种创建它的方法对我有用,但我不知道如何修改其余部分以使它们保持不变,但是用斜线。我感谢那些帮助我和推荐东西的人......非常感谢你。
import discord
from discord import Intents
from discord import app_commands
from discord.ext import commands
import os
import aiohttp
import random
from random import choice
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="/", help_command=None, intents=discord.Intents.all())
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game(name="/help - play.darkgraze.xyz", type=3))
print("El bot esta listo.")
@bot.command(aliases=['8ball'])
async def _8ball(ctx, *, question):
response = ['En mi opinión, sí',
'Es cierto',
'Es decididamente así',
'Probablemente',
'Buen pronóstico',
'Todo apunta a que sí',
'Sin duda',
'Sí',
'Sí - definitivamente',
'Debes confiar en ello',
'Respuesta vaga, vuelve a intentarlo',
'Pregunta en otro momento',
'Será mejor que no te lo diga ahora',
'No puedo predecirlo ahora',
'Concéntrate y vuelve a preguntar',
'Puede ser',
'No cuentes con ello',
'Mi respuesta es no',
'Mis fuentes me dicen que no',
'Las perspectivas no son buenas',
'Muy dudoso']
_8ball_embed = discord.Embed(title=' ', description=f" ", color=discord.Color.blue())
_8ball_embed.add_field(name="Bola mágica | :8ball:", value=f"**Pregunta:** \n{question}\n**Respuesta:** \n{random.choice(response)}")
await ctx.send(embed=_8ball_embed)
@bot.tree.command(name='ping', description='Prueba el funcionamiento del bot.')
async def ping(interaction: discord.Interaction):
await interaction.response.send_message('¡Pong!')
@bot.command()
async def sync(ctx):
await bot.tree.sync()
await ctx.send('¡Listo!')
@bot.command()
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount)
@bot.command()
async def sumar(ctx, numOne: int, numTwo: int):
await ctx.send(numOne + numTwo)
@bot.command()
async def ip(ctx):
embed = discord.Embed(description="""▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**IP:** play.darkgraze.xyz
**Versión:** 1.8 - 1.18
**Soporte:** Java
**Versión recomendada:** 1.8.X
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def apelar(ctx):
embed = discord.Embed(description="""▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**Apelar:** https://foro.darkgraze.xyz/forum/view/8-apelaciones/
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def staffapply(ctx):
embed = discord.Embed(description="""▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**Link:** https://foro.darkgraze.xyz/staff-apply/
**Estado:** Cerradas.
**Próxima apertura:** Indefinido.
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def reglas(ctx):
embed = discord.Embed(description="""▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**Reglas:** https://foro.darkgraze.xyz/rules/
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def reportar(ctx):
embed = discord.Embed(description="""▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**Reportar usuarios:** https://foro.darkgraze.xyz/forum/view/9-reportes/
**Reportar bugs:** https://foro.darkgraze.xyz/forum/view/10-reportes-%28bugs%29/
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def desban(ctx):
embed = discord.Embed(description="""▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**Desbaneo:** https://darkgrazeof.tebex.io/category/unban
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def donar(ctx):
embed = discord.Embed(description="""▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**Donación:** https://darkgrazeof.tebex.io/category/donacion
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def help(ctx):
embed = discord.Embed(title="Comandos de DarkGraze", description="""**» Lista de comandos**
El bot tiene un total de `10` comandos.
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
`!help` ∷ Ver esta lista.
`!ip` ∷ Ver ip del servidor.
`!8ball` ∷ Utiliza la bola mágica.
`!reglas` ∷ Reglas del servidor.
`!sumar` ∷ Has una suma.
`!desban` ∷ Link de desbaneo.
`!apelar` ∷ Link para apelar sanción.
`!donar` ∷ Link para donaciones.
`!reportar` ∷ Link para hacer un reporte.
`!staffapply` ∷ Información staff apply.
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
""", color=0x00E6FF)
await ctx.send(embed=embed)
@bot.command()
async def dkbsay(ctx, *, message):
channel = bot.get_channel(803517045966766150)
await channel.send(f"{message}")
bot.run("token")
我试了很多方法,也用了ChatGPT的帮助,但是没有用,总是报错或者哪里不对