[英]discord python api Bot() and Client()
I am trying to make a discord bot in python and I keep running into a problem. 我试图用python创建一个不和谐的机器人,但我一直遇到问题。 What I am trying to do is use discord.ext.commands.Bot() to run a command to create a channel (which uses discord.Client() ).
我正在尝试使用discord.ext.commands.Bot()运行命令来创建通道(使用discord.Client())。 Whenever I start the bot using bot.run('token'), the client part does not work.
每当我使用bot.run('token')启动bot时,客户端部分均无法正常工作。 But if I run the bot using client.run('token'), I am able to create the channel, but not use the command.
但是,如果我使用client.run('token')运行机器人,则可以创建通道,但不能使用命令。 Is there any way to have both running at the same time, or am I out of luck?
有什么办法可以让两者同时运行,还是我不走运?
The code for the command is: 该命令的代码是:
@bot.command(pass_context=True)
async def channel(ctx):
client.create_channel(ctx.message.server, 'test', type=discord.ChannelType.text)
您不能只使用:
await bot.create_channel(ctx.message.server, 'test', type=discord.ChannelType.text)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.