我正在使用discord.py制作一个新的discord机器人,我想用我的机器人与其他人互动.例如,我将输入"/提及@myfiend",然后我的机器人将回复"Lexanspe提及@myFriend!".但如果没有提到,BOT会回复"你应该提到某人!"
我没有任何 idea ,所以我问了Copilot,它说如果你想用斜杠命令,你应该使用不同的库,但我不知道其他库,所以我又问了一遍,Copilot开始给出愚蠢的答案,其中包含很多错误,所以我想在这里问你.
我也搜索了很多,但所有的论坛都不是关于斜杠命令的,所以我仍然不知道如何查看消息.
下面是我的代码:
import discord
from discord import app_commands
from discord.ext import commands
bot = commands.Bot(command_prefix="!", intents=discord.Intents.default(), activity=discord.Game(name='with arda'))
@bot.event
async def on_ready():
print("started")
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} commands(s)")
except Exception as e:
print(e)
@bot.tree.command(name = "gizli")
async def sa(interaction: discord.Interaction):
await interaction.response.send_message(f"as {interaction.user.mention}, slash komudu calisti ezzzzz", ephemeral=True)
@bot.tree.command(name = "ping")
@app_commands.describe(kimi = "say something")
async def say(interaction: discord.Interaction, kimi: str):
await interaction.response.send_message(f"{interaction.user.mention} mentioned {kimi}")
@bot.tree.command(name = "say")
@app_commands.describe(message = "say something")
async def say(interaction: discord.Interaction, message: str):
await interaction.response.send_message(f"{interaction.user.mention} said {message}")
bot.run("token")
我做了一些类似的东西,但正如我所说的,当有人使用"/ping"时,我如何判断消息?