[英]Disconnecting my bot from Voice channel discord.py
I am giving my bot music aspects, and I am working on joining and leaving voice channels.我正在提供我的机器人音乐方面,我正在努力加入和离开语音频道。
I have searched a lot on the internet before asking, from Stack Overflow, Reddit etc. However, none of these solutions worked or were what I needed.在询问之前,我在互联网上搜索了很多,来自 Stack Overflow、Reddit 等。但是,这些解决方案都没有奏效,也不是我需要的。
My code:我的代码:
@commands.command(pass_context=True)
async def disconnect(self, ctx):
server = ctx.message.guild.voice_client
await server.disconnect()
Things to note:注意事项:
This code is from StackOverflow, yet it doesn't work, my original code didn't work either
此代码来自 StackOverflow,但它不起作用,我的原始代码也不起作用
This is in a seperate file from my join command
这是与我的 join 命令分开的文件
However I am using cogs, and I have used heritage to basically link the 2, so even if they are in seperate files (For organization resaons), they are still part of the same class (cog) called music.
但是,我使用的是齿轮,并且我已经使用传统来基本上将这两个链接起来,因此即使它们在单独的文件中(对于组织原因),它们仍然属于称为音乐的同一类(齿轮)的一部分。
How should I fix my code or change it so that it works?我应该如何修复我的代码或更改它以使其正常工作? Thanks!
谢谢!
这在这里应该有效: await ctx.voice_client.disconnect()
我不确定,因为我还没有测试过,但我很确定它可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.