[英]How to make bot run a slash command discord.py
我正在尝试使用在 repl.it 上运行的 selfbot 发送斜线命令,但它们作为普通消息发送,未被检测为斜线命令。
我知道 discord selfbots 是针对TOS但出于测试目的,我将如何制作它以便它们检测为斜杠命令?
这是代码:
import discord
import os
import keep_alive
from discord.ext import commands, tasks
bot = commands.Bot(command_prefix='!', self_bot=True, help_command=None)
@bot.event
async def on_ready():
print("Bot presence t u r n e d on ( ͡° ͜ʖ ͡°)")
test.start()
@tasks.loop(seconds=10)
async def test():
channel = bot.get_channel(xxx)
await channel.send('/nick test nick')
keep_alive.keep_alive()
bot.run(xxx, bot=False)
谢谢。
Discord 将斜杠命令检测为交互而非实际命令。 从 2022 年 3 月开始,我在网上发现有人在他们的服务器中设置斜杠命令的代码:
@tree.command(guild = discord.Object(id=guild_id), name = 'tester', description='testing') #guild specific slash command
async def slash2(interaction: discord.Interaction):
await interaction.response.send_message(f"I am working! I was made with Discord.py!", ephemeral = True)
## Ephemeral being "true" means it will only display for the user running the command
我希望这是有用的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.