on_voice_state_update()接受2个位置参数,但给出了3个

时间:2018-08-23 17:16:14

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

您好,我收到错误on_voice_state_update() takes 2 positional arguments but 3 were given,但不确定是什么原因导致此错误。我尝试了其他一些方法,它们不断产生相同的Type错误。

这是我正在工作的代码

更新

from discord.ext import commands
import random
from random import randint
import discord
import asyncio

class vtcmention:
    def __init__(self, bot):
        self.bot = bot

    async def on_voice_state_update(self, before, after, member: discord.Member):
        log_channel = self.bot.get_channel(CHANNEL_ID)
        vc_before = before.voice_channel
        vc_after = after.voice_channel
        CHANNEL_ID = '481478695794638859'

        if vc_before == vc_after: return

        if vc_before is None:
            msg = "**{}** joined **{}**".format(member.name, vc_after.name)
        elif vc_after is None:
            msg = "**{}** left **{}**".format(name.name, vc_before.name)
        else:
            msg = "**{}** moved into **{}** from **{}**".format(member.name, vc_before.name, vc_after.name)

        await self.bot.send_message(log_channel, msg)


def setup(bot):
    n = vtcmention(bot)
    bot.add_cog(n)

如果有人可以帮助我解决我在哪里出问题,我将非常感激。 谢谢。

0 个答案:

没有答案