我将如何在齿轮中使用interactions.py?我希望每个命令都有不同的文件,但我不确定如何使用interactions.py来实现这一点。
发布于 2022-08-14 03:00:55
为此,我们使用Extension。下面是在Extension中使用discord.py的一个例子。
Bot主文件:
import interactions
client = interactions.Client(...)
client.load("ext1")
client.command(
name="command_outside",
description"This command is in main bot file",
)
async def _command_outside(ctx: interactions.CommandContext):
await ctx.send("This command is ran outside of Extension.")
client.start()作为扩展名的ext1.py文件,也就是一个齿轮。
import interactions
class Ext(interactions.Extension):
def __init__(self, client: interactions.Client) -> None:
self.client: interactions.Client = client
@interactions.extension_command(
name="command_in_ext",
description"This command is in an Extension",
)
async def _ext_command(self, ctx: interactions.CommandContext):
await ctx.send("This command is ran inside an Extension")
def setup(client):
Ext(client)您可以查看docs 这里。
https://stackoverflow.com/questions/73132277
复制相似问题