python - 让我的机器人加入发送命令的人,而不是让它在预设的 VC 中
问题描述
我的代码目前是这个
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='Music')
await voiceChannel.connect()
我该如何更改它以加入作者而不是加入标有“音乐”的 VC
解决方案
如果您在此之后需要更多帮助,请考虑加入这个小型不和谐服务器。
这是我用于我的代码:
@bot.command()
async def join(ctx):
author = ctx.message.author
channel = author.voice_channel
await bot.join_voice_channel(channel)
推荐阅读
- java - 重构 switch 语句 - 使用对象与原始数据类型
- c# - 如果某个值在不同的文本字段中,则将文本字段设置为 null
- go - 对 goroutine 中的 defer 感到困惑
- r - 是否可以通过海拔对路径进行着色?
- depth-first-search - 当它看起来缺少一些返回调用 (DFS) 时,为什么它会起作用?
- python - PySide2:清理孙线程的正确方法
- docker - Kubernetes 容器失败并卡在 CrashLoopBackOff 状态,且 pod 中没有事件/日志
- swift - RxSwift - 在转换函数中使用函数构造 Observable
- c - 编写一个 Shell 脚本来检查一个 C 程序是否打印 Hello World
- dictionary-comprehension - 在 python 中创建年和月的嵌套字典理解