AttributeError问题'NoneType'对象没有属性'channel'

时间:2019-05-10 16:29:19

标签: python-3.x discord.py discord.py-rewrite

嗨,我正在尝试获取语音通道及其名​​称,但是我遇到了属性错误AttributeError: 'NoneType' object has no attribute 'channel'

await ctx.send(f':white_check_mark: {member.name} was kicked from voice channel: **{member.voice.channel.name}**.')

我不确定是什么导致了此问题:

这是我的代码:

async def voicekick(self, ctx, member: discord.Member):
    """Kicks a member from voice and restricts them from joining all voice channels.

    - member: The member to kick
    """
    vcr = get(ctx.guild.roles, name="VC Restricted")
    if member.voice is None:
        await ctx.send("Member not in VC")
    else:
        await member.move_to(channel=None, reason=None)
        await member.add_roles(vcr)
        await ctx.send(f':white_check_mark: {member.name} was kicked from voice channel: **{member.voice.channel.name}**.')

帮助表示赞赏。

0 个答案:

没有答案