【发布时间】:2022-10-21 01:29:07
【问题描述】:
我的控制台没有显示任何错误,斜杠命令有效,但是当我输入“!dog”时,它应该返回“dog”,但没有任何反应。
'''
import discord
import random
from discord import app_commands
from discord.ext import commands
id_do_servidor = my_server_id
class client(discord.Client):
bot = commands.Bot(command_prefix='!',intents=discord.Intents.all())
def __init__(self):
super().__init__(intents=discord.Intents.default())
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(
guild=discord.Object(id=id_do_servidor)
)
self.synced = True
print(f"{self.user.name} is online.")
aclient = client()
tree = app_commands.CommandTree(aclient)
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.command(name='dog')
async def sapo(ctx):
await ctx.send('dog')
@tree.command(guild=discord.Object(id=id_do_servidor),
name='test',
description='test')
async def slash2(interaction: discord.Interaction):
await interaction.response.send_message(f"Working!",
ephemeral=True)
aclient.run(
'my_bot_token')
'''
如果有人知道解决方案,请帮助我,感谢您的关注。
【问题讨论】:
标签: python discord.py