[英]How to make bot run a slash command discord.py
I'm trying to send slash commands with a selfbot ran on repl.it but they are sent as a normal message and not detected as slash commands.我正在尝试使用在 repl.it 上运行的 selfbot 发送斜线命令,但它们作为普通消息发送,未被检测为斜线命令。
I know discord selfbots are against TOS but for testing purposes how would i make it so that they detect as a slash command?我知道 discord selfbots 是针对TOS但出于测试目的,我将如何制作它以便它们检测为斜杠命令?
Here is the code:这是代码:
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)
Thanks.谢谢。
Discord detects slash commands as an interaction rather than an actual command. Discord 将斜杠命令检测为交互而非实际命令。 I found this code online for someone setting up a slash command in their server from March of 2022:
从 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
I hope this is useful.我希望这是有用的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.