woohyunjng / discord.py-components

An unofficial third-party library of discord.py for discord components.
https://devkiki7000.gitbook.io/discord-components/
MIT License
128 stars 43 forks source link

[Bug] Discord Buttons & Components #8

Closed FeelsBadMan1 closed 3 years ago

FeelsBadMan1 commented 3 years ago

Hey. today discord released the buttons but somehow i find 2 codeexamples in the docs one use buttons and one use components. if i use the components exaple i get a json not seziable error and if i use buttons i get this:

Ignoring exception in on_message
Traceback (most recent call last):
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "D:/my_python_projects/MongoDB Test/mongosetup.py", line 31, in on_message
    m = await msg.channel.send(
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord_buttons\client.py", line 57, in send_button_msg_prop
    return await self.send_button_msg(ctxorchannel, *args, **kwargs)
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord_buttons\client.py", line 150, in send_button_msg
    data = await self.bot.http.request(
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\http.py", line 192, in request
    async with self.__session.request(method, url, **kwargs) as r:
AttributeError: 'NoneType' object has no attribute 'request'

anyone knows a solution?

helish88 commented 3 years ago

same error


AttributeError: 'NoneType' object has no attribute 'from_json'```
Jorgen1040 commented 3 years ago

I have a fix. Just gimmie a moment and I'll set up a PR

Jorgen1040 commented 3 years ago

Nvm. I guess i was a little to quick to read this issue, my PR fixes the error that @helish88 gets. But I think your error stems from using discord-buttons and not the updated discord-components @FeelsBadMan1

FeelsBadMan1 commented 3 years ago

Nvm. I guess i was a little to quick to read this issue, my PR fixes the error that @helish88 gets. But I think your error stems from using discord-buttons and not the updated discord-components @FeelsBadMan1

Okey it is good that you solved to error from the other one that had almost the same. I defently tried both modules buttons aswell as components. while using the components i get this errorlog:

Ignoring exception in on_message
Traceback (most recent call last):
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "D:/my_python_projects/MongoDB Test/mongosetup.py", line 31, in on_message
    await msg.channel.send(
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord_components\client.py", line 58, in send_component_msg_prop
    return await self.send_component_msg(ctxorchannel, *args, **kwargs)
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord_components\client.py", line 152, in send_component_msg
    data = await self.bot.http.request(
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\http.py", line 156, in request
    kwargs['data'] = utils.to_json(kwargs.pop('json'))
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\utils.py", line 328, in to_json
    return json.dumps(obj, separators=(',', ':'), ensure_ascii=True)
  File "D:\Downloads\Python\python 3.8.7\lib\json\__init__.py", line 234, in dumps
    return cls(
  File "D:\Downloads\Python\python 3.8.7\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "D:\Downloads\Python\python 3.8.7\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "D:\Downloads\Python\python 3.8.7\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Button is not JSON serializable