Discord.py“VoiceState”对象没有“voice\u channel”属性

2024-09-30 14:18:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用类结构。我正在写一个不和谐机器人,用于播放声音。但我面临一个问题

我的music.py文件:

import discord
from discord.ext import commands


class muzikkomut(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command(pass_context=True)
        async def play(self, mesaj):
            kanal = mesaj.message.author.voice.voice_channel
            await self.bot.join_voice_channel(kanal)


def setup(bot):
    bot.add_cog(muzikkomut(bot))

Tags: importself声音defbotchannelmusic机器人