변명은 만개 결과는 한개
[Discord] TypeError: __new__() got an unexpected keyword argument 'allow_new' 오류 해결법 본문
[Discord] TypeError: __new__() got an unexpected keyword argument 'allow_new' 오류 해결법
노마십가 2020. 7. 9. 20:58TypeError: __new__() got an unexpected keyword argument 'allow_new'
발생 시 해결법
↓ 오류 전문
TypeError: __new__() got an unexpected keyword argument 'allow_new'
Ignoring exception in on_voice_state_update
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "c:\bot\MY_BOT.py", line 58, in on_voice_state_update
new_channel = await category.create_voice_channel(name="MY_CHANNEL_NAME", overwrites=overwrites,
bitrate=now_channel.guild.bitrate_limit)
File "C:\Python36\lib\site-packages\discord\channel.py", line 860, in create_voice_channel
return await self.guild.create_voice_channel(name, overwrites=overwrites, category=self, reason=reason, **options)
File "C:\Python36\lib\site-packages\discord\guild.py", line 907, in create_voice_channel
channel = VoiceChannel(state=self._state, guild=self, data=data)
File "C:\Python36\lib\site-packages\discord\channel.py", line 561, in __init__
self._update(guild, data)
File "C:\Python36\lib\site-packages\discord\channel.py", line 593, in _update
self._fill_overwrites(data)
File "C:\Python36\lib\site-packages\discord\abc.py", line 311, in _fill_overwrites
id=overridden_id, **overridden))
TypeError: __new__() got an unexpected keyword argument 'allow_new'
3줄요약은 맨 아래 있습니다
기존에 잘 동작하던 채널 자동 생성 봇이 고장이 났다.
위 접힌 로그를 보시면 아시겠지만 on_voice_state_update 의 create_voice_channel 의 _fill_overwrites 에서 오류가 발생했다.
이는 채널 권한을 부여하는 딕셔너리 인자인 overwrites 안에 알수없는 keyword (위에선 allow_new) 가 들어있었다는 말이었고
실제로 allow_new 같은 인자는 api상에 존재하지 않았다.
API Reference — discord.py 1.4.0a documentation
API Reference The following section outlines the API of discord.py. Note This module uses the Python logging module to log diagnostic and errors in an output independent way. If the logging module is not configured, these logs will not be output anywhere.
discordpy.readthedocs.io
궁금해서 실제 _fill_overwrites 쪽에 넘어가는 data ( overwrites 포함 ) 을 까보니
'permission_overwrites':
[
{'id': '000000000000000000', 'type': 'member', 'allow': 16, 'deny': 0, 'allow_new': '16', 'deny_new': '0'},
{'id': '000000000000000000', 'type': 'role', 'allow': 0, 'deny': 1024, 'allow_new': '0', 'deny_new': '1024'},
{'id': '000000000000000000', 'type': 'role', 'allow': 1024, 'deny': 0, 'allow_new': '1024', 'deny_new': '0'}
]
위 처럼 allow_new 및 allow_deny 가 각각 allow 및 deny 의 값을 가진채로 전달되고있었다.
그래서 unexpected keyword argument 가 발생한것.
해결법은 간단하게 discord.py 파일을 업데이트 시켜주면 된다.
빌드하는 서버 기준 아래 명령어로 discord.py 파일을 업데이트 한 뒤 빌드시 정상 동작한다.
python -m pip install -U discord.py
끝!
세줄요약
1. discord.PermissionOverwrite 을 overwrites 인자로 넘기면 "allow_new" 와 같이 정의되지 않은 인자가 넘어가 에러발생
2. discord.py 1.3.3 버전에서 문제 발생, 1.3.4 버전에 수정 완료
3. 빌드하는 서버 기준 "python -m pip install -U discord.py" 로 discord.py 업데이트 후 빌드시 정상동작
'공부 > Discord' 카테고리의 다른 글
[Discord] bot.command 와 on_message 같이쓰기 (3) | 2020.09.03 |
---|---|
[Discord] 휴면 계정 리스트업 로직 (0) | 2020.09.01 |
[Discord Python bot] dm file send 에러 - WinError 10054 현재 연결은 원격 호스트에 의해 강제로 끊겼습니다 (0) | 2020.07.07 |
[Discord python bot] 봇 실행시 / 메세지 수신시 event (0) | 2020.06.25 |
Visual Studio Code 에서 Unable to import 'package' 뜰때 (0) | 2020.06.25 |