我得到了这个错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'voice_channel'通过使用以下代码:
from discord.ext import commands
import discord
class Voice(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(name='join')
async def join(self, ctx):
channel = ctx.message.author.voice.voice_channel
print(str(channel))
def setup(client):
client.add_cog(Voice(client))找不到为什么它不工作:/我用完全相同的代码看了一个yt视频,但它在那里工作...
发布于 2021-02-01 04:47:10
因为作者可以使用此命令,尽管他不在语音通道中,也没有语音对象。您可以使用try和except或if来检查语音对象是否为空。
https://stackoverflow.com/questions/65983907
复制相似问题