将 discord.py bot 添加到语音通道

时间:2021-07-07 12:52:13

标签: python discord discord.py

我正在尝试使用 discord.py 将我的机器人连接到语音通道,但它对我来说不太好......关于我如何改进它的任何帮助?

[complete] ENTERED

错误:

...
const uploadTask: AngularFireUploadTask = this.storage.upload(filePath, fileToUpload);
...
uploadTask.snapshotChanges()
              .pipe(
                filter(task => {
                  if (task) {
                    return task.state === firebase.storage.TaskState.SUCCESS
                  }
                  return false;
                })
              )
              .subscribe(val => {
                this.gcpService.getLog(filePath)
                  .subscribe({
                    next: data => console.log('[next] ENTERED'),
                    complete: () => {
                      console.log('[complete] ENTERED');
                    }
                  });
              })
...

我也有这个代码:

    @bot.command(pass_context=True)
    async def join(ctx):
        channel = ctx.author.voice.channel
        await bot.join_voice_channel(channel)

它没有错误 - 它只是什么都不做...

1 个答案:

答案 0 :(得分:0)

要加入频道,请使用 await VoiceChannel.connect()

所以对于你的例子来说就是

@bot.command()
async def join(ctx):
    channel = ctx.author.voice.channel
    await channel.connect()

同样 pass_context 已被弃用。

对于你的第二个例子

@bot.command()
async def play(ctx, url: str, channel: discord.VoiceChannel):
    await channel.connect()

我猜只是一个错字,您必须使用 : 来声明参数类型。