dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
683 stars 162 forks source link

unable to use slash-commands #265

Closed someuser32 closed 2 years ago

someuser32 commented 2 years ago

Summary

KeyError: 'dm_permission'

Reproduction Steps

  1. poetry add git+https://github.com/dolfies/discord.py-self@rebase
  2. python3 main.py

Code

import discord, asyncio

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} started')
    channel = client.get_channel(ID)
    async for cmd in channel.slash_commands(query="pin"):
        if cmd.name == "ping":
            await cmd()

client.run(TOKEN)

Expected Results

use /ping

Actual Results

Traceback (most recent call last): File "/home/runner/bottest/venv/lib/python3.8/site-packages/discord/client.py", line 329, in _run_event await coro(*args, kwargs) File "main.py", line 9, in on_ready async for cmd in channel.slash_commands(query="pin"): File "/home/runner/bottest/venv/lib/python3.8/site-packages/discord/iterators.py", line 128, in anext return await self.next() File "/home/runner/bottest/venv/lib/python3.8/site-packages/discord/iterators.py", line 669, in next await self.fill_commands() File "/home/runner/bottest/venv/lib/python3.8/site-packages/discord/iterators.py", line 720, in fill_commands self.commands.put_nowait(self.create_command(cmd)) File "/home/runner/bottest/venv/lib/python3.8/site-packages/discord/iterators.py", line 731, in create_command return self.cls(state=channel._state, data=data, channel=channel, kwargs) File "/home/runner/bottest/venv/lib/python3.8/site-packages/discord/commands.py", line 436, in init super().init(data=data, **kwargs) File "/home/runner/bottest/venv/lib/python3.8/site-packages/discord/commands.py", line 168, in init self._dm_permission = data['dm_permission'] KeyError: 'dm_permission'

System Information

pkg_resources.DistributionNotFound: The 'discord.py' distribution was not found and is required by the application

Checklist

Additional Information

No response

dolfies commented 2 years ago

Looks like discord changed some payloads.

dolfies commented 2 years ago

Fixed in latest master commit.

mrcrien commented 2 years ago

im using rebase branch, slash commands stop working yesterday. it gives no error but no slash command executed too

dolfies commented 2 years ago

Use the master branch rebase was a temporary branch that was merged into master a while ago

magraaa commented 2 years ago

I am getting this error AttributeError: 'TextChannel' object has no attribute 'slash_commands'