Code Monkey home page Code Monkey logo

disnake's People

Contributors

abhigyantrips avatar abstractumbra avatar apple502j avatar bijij avatar bryanforbes avatar diceroll123 avatar elenakrittik avatar equenos avatar gorialis avatar harmon758 avatar hornwitser avatar imayhaveborkedit avatar ioistired avatar jackenmen avatar khazhyk avatar lostluma avatar mikeshardmind avatar ncplayz avatar onerandomusername avatar rapptz avatar sebbylaw avatar sharp-eyes avatar shiftinv avatar snipy7374 avatar stockermc avatar thesadru avatar vexs avatar victorsitou avatar xuathegrate avatar zomatree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

disnake's Issues

`ThreadPayload` does not always contain `owner_id`

Summary

Passing a thread to a slash command will result in the bot shutting down. The cause for this is that the owner ID is missing within the payload.

Reproduction Steps

Reproduction steps:
1). Create a slash command that has the channels OptionType
2). Run the command within Discord and pass a thread to it

Traceback:

Traceback (most recent call last):
  File "bot.py", line 98, in <module>
    libertas_support.run()
  File "bot.py", line 76, in run
    super().run(environ.get('TOKEN'))
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\client.py", line 795, in run
    return future.result()
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\client.py", line 774, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\client.py", line 738, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\client.py", line 644, in connect
    await self.ws.poll_event()
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\gateway.py", line 568, in poll_event
    await self.received_message(msg.data)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\gateway.py", line 518, in received_message
    func(data)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\state.py", line 806, in parse_interaction_create
    interaction = ApplicationCommandInteraction(data=data, state=self)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\interactions\application_command.py", line 115, in __init__
    self.data = ApplicationCommandInteractionData(
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\interactions\application_command.py", line 214, in __init__
    self.resolved = ApplicationCommandInteractionDataResolved(
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\interactions\application_command.py", line 380, in __init__
    self.channels[int(str_id)] = factory(guild=guild, state=state, data=channel) # type: ignore
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\threads.py", line 152, in __init__
    self._from_data(data)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\threads.py", line 170, in _from_data
    self.owner_id = int(data['owner_id'])
KeyError: 'owner_id'

Minimal Reproducible Code

@commands.slash_command(
    name='test',
    options=[
        disnake.Option(
            name='thread',
            type=disnake.OptionType.channel,
            required=True,
            channel_types=[disnake.ChannelType.private_thread],
        ),
    ],
)
async def test(
    self,
    interaction: disnake.ApplicationCommandInteraction,
    thread: disnake.Thread,
) -> None:
    pass

Expected Results

I expect a thread to be returned.

Actual Results

The bot shuts down.

Intents

NA

System Information

  • Python v3.8.6-final
  • disnake v2.1.2-alpha
    • disnake pkg_resources: v2.1.2
  • aiohttp v3.6.2
  • system info: Windows 10 10.0.1904

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Slash commands not working on mobile

Summary

When I try to use slash commands on mobile they don't work

Reproduction Steps

go on mobile and use slash commands

Minimal Reproducible Code

No response

Expected Results

image
it comes up with the embed

Actual Results

image

Intents

members

System Information

  • Python v3.8.12-final
  • disnake v2.1.4-beta
    • disnake pkg_resources: v2.1.4
  • aiohttp v3.7.4.post0
  • system info: Linux 5.11.0-1021-gcp #23~20.04.1-Ubuntu SMP Fri Oct 1 19:04:32 UTC 2021

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Known bug with cogs context menus commands on Python 3.10

Summary

It seems that context menus commands in cogs aren't working on Python 3.10.

However, the current GitHub version seems to fix that, so I'll leave this issue just to make sure it's a known bug, but this will be fixed in the next version. (Probably 2.3)

shiftinv figured out why it was happening, full conversation here.

Guild.timeout doesn't work

Summary

Guild.timeout(Member) is not working

Reproduction Steps

  1. get member from guild object
  2. run timeout by Guild.timeout()

Minimal Reproducible Code

member = guild.get_member(123456789012345678)
await guild.timeout(user=member, seconds=10, reason="some reason")

Expected Results

This should put user in timeout.

Actual Results

It actually returns

disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In user_id: Value "member's name" is not snowflake.

Intents

disnake.Intents.all()

System Information

Windows Server 2019, 64-bit
Python 3.9.7
disnake @ latest commit in master

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

It actually works when use

await guild.timeout(user=123456789012345678)

commands.Group() for slash commands

Summary

commands.Group(), but for slash commands (sub-commands)

What is the feature request for?

disnake.ext.commands

The Problem

I am trying to use sub-commands (for slash commands) with commands.Bot, but the only Group I found in the documentation is commands.Group() which is for regular commands.

The Ideal Solution

Adding something like commands.SlashCommandGroup() that will allow us to make sub-commands with commands.SlashCommandGroup().slash_command()

The Current Solution

No response

Additional Context

No response

`disnake.Member.status` and `disnake.Member.raw_status` not working well.

Summary

While trying to get user's status it returns offline in Slash Commands, even though the user isn't offline.

Reproduction Steps

When trying to get user's status in a @bot.command() command it works well and it returns the correctly status, but when using it in a @bot.slash_command, it returns offline. (I don't know if it works well in context menus)

Also, it just works when you have both Members and Presences intents.

Minimal Reproducible Code

Prefix commands that I'm using:

@bot.command()
async def status(ctx):
    # This one works well
    await ctx.send(ctx.author.status)

Slash commands that I'm using:

@bot.slash_command(name="status")
async def status(
    inter: disnake.ApplicationCommandInteraction,
    user: disnake.Member = commands.Param(description="user"),
):
    # This one returrns offline
    await inter.response.send_message(f"Your status is {user.status}")

Extra comment: Using `disnake.ApplicationCommandInteraction.author.status` returns also offline.

Expected Results

Get the user's status.

Actual Results

Returning offline in Slash Commands.

Intents

Presences and Members

Important comment:
It seems that using this way to use intents doesn't work (I may be wrong but at least for the code listed above didn't work)

intents = disnake.Intents()
intents.members = True
intents.presences = True

The way I used to use intents is this one:

intents = disnake.Intents.default()
intents.members = True
intents.presences = True

System Information

  • Python v3.10.0-final
  • disnake v2.2.1-beta
    • disnake pkg_resources: v2.2.1
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19042

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Add `Client` methods that wrap all `HTTPClient` methods related to app commands

Summary

HTTPClient has several methods for app commands which are not represented in Client

What is the feature request for?

The core library

The Problem

HTTPClient methods only work with dicts and return only dicts. Client methods will wrap all of that pretty nicely.

The Ideal Solution

The Current Solution

No response

Additional Context

No response

Typing events for DMs don't get dispatched

Summary

ConnectionState._get_guild_channel uses DMChannel._from_message, which always sets recipient to None. This applies to both parse_message_create and parse_typing_start, and results in the typing event not being dispatched (among other things):

disnake/disnake/state.py

Lines 1687 to 1688 in 6fe2b89

if isinstance(channel, DMChannel):
member = channel.recipient

disnake/disnake/state.py

Lines 1702 to 1706 in 6fe2b89

if member is not None:
timestamp = datetime.datetime.fromtimestamp(
data.get("timestamp"), tz=datetime.timezone.utc
)
self.dispatch("typing", channel, member, timestamp)

Expected Results

The typing event gets dispatched

Actual Results

it doesn't get dispatched (duh)

Intents

all

Additional Context

https://discord.com/channels/808030843078836254/883342278280745030/914696216850354196

on_message_interaction doesn't work properly

Summary

When clicking on a button, the bot will receive an unknown interaction while it has not restarted.

Reproduction Steps

  • Create an on_message_interaction event and write the code to respond this inter inside the on_message_interaction event.
  • Create a command which sends a message with a button.
  • Start the bot.
  • Invoke the command.
  • Click the button.
  • The event will raise a disnake.errors.NotFound error.
  • Restart the bot.
  • Click on the button sent before (do not reinvoke the command).
  • The event will return the proper interaction instead of disnake.NotFound.

Minimal Reproducible Code

import disnake
from disnake.ext import commands


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

    @commands.slash_command(guild_ids=["ids"])
    async def test(self, inter):
        view = disnake.ui.View()
        view.add_item(disnake.ui.Button(style=disnake.ButtonStyle.blurple, emoji="โค"))
        await inter.response.send_message("Do you love me?", view=view)

    @commands.Cog.listener()
    async def on_message_interaction(self, inter):
        await inter.response.send_message(f'You interacted with a component', ephemeral=True)


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

Expected Results

The inter.response.send_message responds to the message interaction without restarting the bot.

Actual Results

The inter.response.send_message doesn't respond to the message interaction without restarting the bot.

Intents

None

System Information

  • Python v3.10.0-final
  • disnake v2.1.5-beta
    • disnake pkg_resources: v2.1.5
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19042

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

from that message to that message
on disnake & dislash.py (https://discord.gg/gJDbCw8aQy)

Write a new readme

Summary

Change the readme entirely to be different than the inherited readme

What is the feature request for?

The documentation

The Problem

Readme looks the same as every other fork.

The Ideal Solution

New readme, new format, new examples. Showcase what disnake has to offer.

The Current Solution

No response

Additional Context

No response

Unable to install disnake on my Raspberry Pi

Summary

Unable to install disnake on my Raspberry Pi

Reproduction Steps

Raspberry Pi configuration :

OS: Raspbian GNU/Linux 10 (buster) armv7l
Host: Raspberry Pi 4 Model B Rev 1.4
Kernel: 5.4.83-v7l+
Uptime: 6 days, 13 hours, 12 mins
Packages: 784 (dpkg)
Shell: bash 5.0.3
Terminal: /dev/pts/0
CPU: BCM2711 (4) @ 1.500GHz
Memory: 255MiB / 1867MiB

Description of the problem :

My raspberry pi is running python version 3.7.3.

I'm trying to run a bot that I coded locally (on mac OS Big Sur) on my raspberry Pi, that I'm accessing via SSH.
I created a new python3 virtual environment (python3 -m venv envi) that I activated doing (source envi/bin/activate), as usual. The environment is activated as it should be and running (python3 -m pip list) returns

Package       Version
------------- -------
pip           21.3.1
pkg_resources 0.0.0
setuptools    40.8.0

just as expected.

Installing disnake

I'm then trying to run the command python3 -m pip install disnake, as usual (I normally use a requirements.txt file but the error is the exact same, so let's keep the most minimal example.).

But then I get this error message :

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
ERROR: Could not find a version that satisfies the requirement disnake (from versions: none)
ERROR: No matching distribution found for disnake

Could it be possible that the pip depots are not the same on mac OS and raspbian ? If so, how can I install disnake on my raspberry ? I mean, Python is still Python and the library should work everywhere...

Thanks for your help ! I tried to be as precise as possible but if my issue is not complete enough, just tell me and I'll do my best to correct it.

Minimal Reproducible Code

python3 -m  pip install disnake

Expected Results

disnake installing successfully

Actual Results

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
ERROR: Could not find a version that satisfies the requirement disnake (from versions: none)
ERROR: No matching distribution found for disnake

Intents

Not relevant here, I guess

System Information

see "how to reproduce" tab to see my system information

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

"GuildCommandInteraction" is not a known member of module

Summary

Code from examples dont work

Reproduction Steps

I inserted the code from the examples into the project

Minimal Reproducible Code

https://github.com/EQUENOS/disnake/blob/master/examples/slash_commands/param.py


# Commands may be limited only to guilds with a special interaction annotation
@bot.slash_command()
async def guild_command(
    inter: disnake.GuildCommandInteraction
) -> None:
    ...

Expected Results

That the code will work

Actual Results

The code doesn't work

Intents

None

System Information

$ pip show disnake
Name: disnake
Version: 2.1.2
Summary: A Python wrapper for the Discord API
Home-page: https://github.com/EQUENOS/disnake
Author: Rapptz, EQUENOS
Author-email:
License: MIT
Location: /home/lev145/PycharmProjects/MusicBot/venv/lib/python3.9/site-packages
Requires: aiohttp
Required-by: discord-disnake

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

I love cats

Delayed command sync is not cancelled on termination

Summary

Delayed command sync is not cancelled on termination

Reproduction Steps

When shutting down the bot, the delayed_command_sync task fails to be cancelled as it's in a pending state. Note that this occurs when no slash commands are registered.

ERROR:asyncio:Task was destroyed but it is pending!
task: <Task pending name='disnake: delayed_command_sync' coro=<InteractionBotBase._delayed_command_sync() done, defined at disnake/ext/commands/interaction_bot_base.py:795> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x10af24160>()]>>

Minimal Reproducible Code

No response

Expected Results

There should not be unhandled errors when shutting down.

Actual Results

There are internal errors on shutdown.

Intents

N/A

System Information

EQUENOS/disnake@74403d4

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Add support for fail_if_not_exists to discord.Message.reply

Summary

Add support for fail_if_not_exists to discord.Message.reply

What is the feature request for?

The core library

The Problem

I'd like to use ctx.reply (which shortcuts to ctx.message.reply) to reply to a message, however the invoke may have been deleted before the command. It would be nice to fully support message references, and be able to pass fail_if_not_exists as false to ctx.reply.

Narrowing this down, I see two solutions

The Ideal Solution

The clear solution is to add fail_if_not_exists to Message.reply()

The question is how, since looking at the implementation, making a reference just to set it to False seems not the best.

I feel like adding a property to the Message objects, fail_if_not_exists and using that for the replies would make the most sense. This would be set if provided to the reply method

There's a few implementations here, but it should make sure to not create objects to just not use them in the next method.

The Current Solution

Currently a user has to create a reference from a method and set fail_if_not_exists to False, then pass the reference to ctx.send.

Being able to just pass fail_if_not_exists to a reply method would be awesome.

Additional Context

No response

Thread archive enum

Summary

Enum to be able to quickly access thread archive limits

What is the feature request for?

The core library

The Problem

Current usage to archive a thread requires setting the close time yourself, it would be nice to have a disnake maintained enum.

Right now, we have to pass 1440 to the archive duration manually.

The Ideal Solution

a enum part of the public api somewhat like the below:

class ThreadArchive(enum.Enum):
    HOUR = 60
    DAY = 1440
    THREE_DAY = 4320
    WEEK = 10080

The Current Solution

Current solution is defining this ourselves

Additional Context

No response

Return a disnake.Message object when inter.send() -ing

Summary

Doing ctx.send with disnake.Context returns a disnake. Message object, while inter.send doesn't return anything. I suggest to return the message

What is the feature request for?

The core library

The Problem

Disclaimer: I'm going to use ctx as a keyword, but that's still an interaction.
If I use ctx.send('Hello world') in a message command (with disnake.Context), the method returns a disnake.Message.
In the contrary, using ctx.send('Hello world') in a slash command, component... (with disnake.Interaction), the method doesn't return anything.

The Ideal Solution

Using ctx.send('Hello world') with disnake.Interaction returns a disnake.Message object.

The Current Solution

Using ctx.send('Hello world') with disnake.Interaction doesn't return anything (because the API doesn't return anything, I consider fetching the message after sending it to return an object).

Additional Context

No response

Slash commands not usable in direct message

Summary

Slash commands can not be used in a direct message, as they error.

Reproduction Steps

Create a global command, and try to invoke it in a direct message.

Minimal Reproducible Code

No response

Expected Results

The command works.

Actual Results

An error occurs:

AttributeError: 'PartialMessageable' object has no attribute 'permissions_for'
  File "disnake/ext/commands/slash_core.py", line 562, in invoke
    await self.invoke_children(inter)
  File "disnake/ext/commands/slash_core.py", line 547, in invoke_children
    await subcmd.invoke(inter, **kwargs)
  File "disnake/ext/commands/slash_core.py", line 271, in invoke
    return await super().invoke(inter, *args, **kwargs)
  File "disnake/ext/commands/base_core.py", line 281, in invoke
    await self.prepare(inter)
  File "disnake/ext/commands/base_core.py", line 204, in prepare
    if not await self.can_run(inter):
  File "disnake/ext/commands/base_core.py", line 523, in can_run
    return await async_all(predicate(inter) for predicate in predicates)  # type: ignore
  File "disnake/utils.py", line 554, in async_all
    for elem in gen:
  File "disnake/ext/commands/base_core.py", line 523, in <genexpr>
    return await async_all(predicate(inter) for predicate in predicates)  # type: ignore
  File "disnake/ext/commands/core.py", line 2060, in predicate
    permissions = ch.permissions_for(ctx.author)  # type: ignore
CommandInvokeError: Command raised an exception: AttributeError: 'PartialMessageable' object has no attribute 'permissions_for'
  File "disnake/client.py", line 505, in _run_event
    await coro(*args, **kwargs)
  File "apollo/cogs/command_error/__init__.py", line 29, in on_slash_command_error
    raise error
  File "disnake/ext/commands/interaction_bot_base.py", line 1297, in process_application_commands
    await app_command.invoke(interaction)
  File "disnake/ext/commands/slash_core.py", line 578, in invoke
    raise CommandInvokeError(exc) from exc

Intents

N/A

System Information

2.2.2

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Lower level component interface

Summary

lower level component iterface that doesn't involve views

What is the feature request for?

The core library

The Problem

disnake.ui.View requires a lot of code for some complex features. I'd like to be able to use components at a lower level. Because on_message_interaction exists in the dispatched events, that is usable after sending the component. However, a view has to be used to send components with disnake.abc.Messegeable.send

The Ideal Solution

A solution here seems like it would be in the source of send, to expose components as a kwarg, and document how to pass buttons and the like to that.

The Current Solution

Make a view and send that, but then intercept the params with on_message_component.

Additional Context

No response

Add PermissionsConverter to disnake/ext/commands/converter.py

Summary

Add PermissionsConverter to disnake/ext/commands/converter.py, so we can use disnake.Permissions as a converter in function defenitions, like disnake.Member or disnake.Channel

What is the feature request for?

disnake.ext.commands

The Problem

There is a code i used to implement converter for disnake.Permissions in my bot:

def PermissionsConverter(value):
	if value == None:
		return discord.Permissions.none()

	try:
		value = int(value)
	except ValueError:
		pass

	if isinstance(value, int):
		return disnake.Permissions(permissions=value)

	else:
		v = value.lower()
		if v == 'advanced':
			return disnake.Permissions.advanced()

		elif v == 'all':
			return disnake.Permissions.all()

		elif v == 'all_channel':
			return disnake.Permissions.all_channel()

		elif v == 'general':
			return disnake.Permissions.general()

		elif v == 'membership':
			return disnake.Permissions.membership()

		elif v == 'none':
			return disnake.Permissions.none()

		elif v == 'stage':
			return disnake.Permissions.stage()

		elif v == 'stage_moderator':
			return disnake.Permissions.stage_moderator()

		elif v == 'text':
			return disnake.Permissions.text()

		elif v == 'voice':
			return disnake.Permissions.voice()

		else:
                        v = v.replace(',', '')
			v = v.split(' ')
			P = disnake.Permissions()
			for perm in v:
				if perm == 'add_reactions':
					P.add_reactions = True

				elif perm == 'administrator':
					P.administrator = True

				elif perm == 'attach_files':
					P.attach_files = True

				elif perm == 'ban_members':
					P.ban_members = True

				elif perm == 'change_nickname':
					P.change_nickname == True

				elif perm == 'connect':
					P.connect == True

				elif perm == 'create_instant_invite':
					P.create_instant_invite == True

				elif perm == 'create_private_threads':
					P.create_private_threads == True

				elif perm == 'create_public_threads':
					P.create_public_threads == True

				elif perm == 'deafen_members':
					P.deafen_members == True

				elif perm == 'embed_links':
					P.embed_links == True

				elif perm == 'external_emojis':
					P.external_emojis == True

				elif perm == 'external_stickers':
					P.external_stickers == True

				elif perm == 'kick_members':
					P.kick_members == True

				elif perm == 'manage_channels':
					P.manage_channels == True

				elif perm == 'manage_emojis':
					P.manage_emojis == True

				elif perm == 'manage_emojis_and_stickers':
					P.manage_emojis_and_stickers == True

				elif perm == 'manage_events':
					P.manage_events == True

				elif perm in ['manage_guild', 'manage_server']:
					P.manage_guild == True

				elif perm == 'manage_messages':
					P.manage_messages == True

				elif perm == 'manage_nicknames':
					P.manage_nicknames == True

				elif perm == 'manage_permissions':
					P.manage_permissions == True

				elif perm == 'manage_roles':
					P.manage_roles == True

				elif perm == 'manage_threads':
					P.manage_threads == True

				elif perm == 'manage_webhooks':
					P.manage_webhooks == True

				elif perm == 'mention_everyone':
					P.mention_everyone == True

				elif perm == 'move_members':
					P.move_members == True

				elif perm == 'mute_members':
					P.mute_members == True

				elif perm == 'priority_speaker':
					P.priority_speaker == True

				elif perm == 'read_message_history':
					P.read_message_history == True

				elif perm == 'read_messages':
					P.read_messages == True

				elif perm == 'request_to_speak':
					P.request_to_speak == True

				elif perm == 'send_messages':
					P.send_messages == True

				elif perm == 'send_messages_in_threads':
					P.send_messages_in_threads == True

				elif perm == 'send_tts_messages':
					P.send_tts_messages == True

				elif perm == 'speak':
					P.speak == True

				elif perm == 'stream':
					P.stream == True

				elif perm == 'use_external_emojis':
					P.use_external_emojis == True

				elif perm == 'use_external_stickers':
					P.use_external_stickers == True

				elif perm == 'use_slash_commands':
					P.use_slash_commands = True

				elif perm == 'use_voice_activation':
					P.use_voice_activation = True

				elif perm == 'view_audit_log':
					P.view_audit_log = True

				elif perm == 'view_channel':
					P.view_channel = True

				elif perm == 'view_guild_insights':
					P.view_guild_insights = True

				else:
					pass
			return P

The command where I used this converter:

@bot.command(name="create role")
async def create_role(ctx, name: str, color: disnake.Color, *, permissions: PermissionsConverter = None):
    pass

So, if user does not provide permssions for role, PermissionsConverter returns disnake.Permissions.none(). Also, if user provided 'none', PermissionsConverter too returns disnake.Permissions.none().
If user provided a "keyword" string, such as advanced or general, PermissionsConverter returns a special group of permissions, e.g.:

"advanced" -> return disnake.Permissions.advanced()
"general" -> return disnake.Permissions.general()
"stage_moderator" -> return disnake.Permissions.stage_moderator()

If string that user provided can be converted to int, PermissionsConverter returns disnake.Permissions with value=int(string_that_user_provided), e.g.:

"8" -> return disnake.Permissions(value=8) # Administrator perms
"2013274160" -> return disnake.Permissions(value=2013274160) # All "manage_" permissions
"2148006976" -> return disnake.Permissions(value=2148006976) # All text permissions

If any trigger was triggered, PermissionsConverter trying to split() string and "extract" permissions from created list.
Example:

# P = disnake.Permissions()
"manage_roles administrator" ->
    P.manage_roles = True
    P.administrator = True
    return P
"view_audit_log manage_guild mention_everyone" ->
    P.view_audit_log = True
    P.manage_guild = True
    P.mention_everyone = True
    return P

The Ideal Solution

Add my code to disnake/ext/commands/converter.py :)

The Current Solution

No response

Additional Context

I'm cheking that string can be converted to int by doing so:

try:
    value = int(value)
except ValueError:
    pass
if isinstance(value, int):
    return disnake.Permissions(value=value)

I'm used this permissions calculator.

Because many users may don't understand what means guild, permission manage_guild aliased as manage_server

Unable to fetch message that triggered interaction

Summary

Unable to fetch message that triggered interaction

Reproduction Steps

  • Create slash command
  • Attempt to resolve the trigger message by awaiting Interaction#original_message
  • Error is produced

Minimal Reproducible Code

@commands.slash_command()
async def ping(inter: disnake.ApplicationCommandInteraction):
    msg = await inter.original_message()
    print(msg.author.id)

Expected Results

Interaction#original_message to resolve as an instance of InteractionMessage

Actual Results

The following error is produced even if the message still exists:
disnake.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook

Traceback:

bot_1  | Traceback (most recent call last):
bot_1  |   File "/usr/local/lib/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 482, in invoke
bot_1  |     await self(inter, **kwargs)
bot_1  |   File "/usr/local/lib/python3.9/site-packages/disnake/ext/commands/base_core.py", line 145, in __call__
bot_1  |     return await self.callback(self.cog, interaction, *args, **kwargs)
bot_1  |   File "/app/cmds/eval.py", line 19, in eval
bot_1  |     msg = await inter.original_message()
bot_1  |   File "/usr/local/lib/python3.9/site-packages/disnake/interactions/base.py", line 264, in original_message
bot_1  |     data = await adapter.get_original_interaction_response(
bot_1  |   File "/usr/local/lib/python3.9/site-packages/disnake/webhook/async_.py", line 189, in request
bot_1  |     raise NotFound(response, data)
bot_1  | disnake.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
bot_1  | 
bot_1  | The above exception was the direct cause of the following exception:
bot_1  | 
bot_1  | Traceback (most recent call last):
bot_1  |   File "/usr/local/lib/python3.9/site-packages/disnake/ext/commands/bot.py", line 1887, in process_application_commands
bot_1  |     await app_command.invoke(interaction)
bot_1  |   File "/usr/local/lib/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 491, in invoke
bot_1  |     raise CommandInvokeError(exc) from exc
bot_1  | disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10015): Unknown Webhook

Intents

Default + Members

System Information

  • Python v3.9.7-final
  • disnake v2.1.2-alpha
    • disnake pkg_resources: v2.1.2
  • aiohttp v3.7.4.post0
  • system info: Linux 5.10.47-linuxkit #1 SMP PREEMPT Sat Jul 3 21:50:16 UTC 2021

Running in a Docker container based on python:3.9-slim-buster

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Add slash commands permissions

Summary

Discord added a way to provide slash commands for only some of the users.

What is the feature request for?

disnake.ext.commands

The Problem

Discord added a way to provide slash commands for only the members who have the permission. Currently, we can't use this feature with the library.

The Ideal Solution

I would like the library to add a permission parameter to the commands.slash_command object, to use this feature.

The Current Solution

No response

Additional Context

Discord API for permissions

Support for converters

Summary

Add support for converters for slash command options

What is the feature request for?

disnake.ext.commands

The Problem

I cannot eassaly use power of converters in slash commands.

The Ideal Solution

@commands.slash_command(
        description = '...',
        options = [disnake.Option('name', 'description', disnake.OptionType.string, True, converter=CustomConverter)]
    )
async def test(self, interaction, name):
    ...

or

@commands.slash_command(
        description = '...',
        options = [disnake.Option('name', 'description', disnake.OptionType.string, True)]
    )
async def test(self, interaction, name: CustomConverter):
    ...

The Current Solution

@commands.slash_command(...)
async def test(self, interaction, name):
    converted = CustomConverter().convert(interaction, name)

Additional Context

Maybe, for custom converters slash_convert (or something different to convert) will be called instead of convert

Discord gives error if integer is too high

Summary

When assigning a slash command parameter to and integer and then putting a really long number as the parameter in your Discord client, Discord will give an error.

Reproduction Steps

  1. Use code snippet to create bot
  2. Run the code
  3. Add bot to server with appropriate permissions and scopes
  4. Run slash command and set the integer parameter to a really long number like 900384081332797542

Minimal Reproducible Code

import disnake
from disnake.ext import commands

bot = commands.Bot(command_prefix=';')

@bot.slash_command(name='test', description='Test command for long number')
async def test(inter, integer: int):
  await inter.response.send_message('Test succesful')

bot.run('TOKEN')

Expected Results

I expected the number to be usable. The integer is an emoji id so it's going to be unavoidably long.

Actual Results

Discord rejected then number. I don't know if this is a problem with this library or some limitation with Discord though.

Intents

None

System Information

  • Python v3.8.6-final
  • disnake v2.2.1-beta
    • disnake pkg_resources: v2.2.1
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19041

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

If something doesn't make sense, I can clarify.

Add `channel_types` param to `commands.Param`

Summary

Currently, there is no way to only allow for private threads. This feature request would allow for that.

What is the feature request for?

disnake.ext.commands

The Problem

Currently, there is no way to only allow for private threads. This feature request would allow for that.

The Ideal Solution

The option to pass channel types to commands.Param.

The Current Solution

NA

Additional Context

No response

Converting to thread results in an exception

Summary

I'm using the disnake.Thread annotation in my slash command, but the conversion spits out an exception.

Reproduction Steps

Reproduction steps:
1). Create a slash command that has the channels OptionType. This option should only allow thread channel types
2). Annotate disnake.Thread for your channel/thread parameter
3). Run the command within Discord and pass a thread to it

Traceback:

Traceback (most recent call last):
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\params.py", line 253, in convert_argument
    return await argument
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\converter.py", line 608, in convert
    return GuildChannelConverter._resolve_thread(ctx, argument, "threads", disnake.Thread)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\converter.py", line 465, in _resolve_thread
    match = IDConverter._get_id_match(argument) or re.match(r"<#([0-9]{15,20})>$", argument)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\converter.py", line 145, in _get_id_match
    return _ID_REGEX.match(argument)
TypeError: expected string or bytes-like object

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1296, in process_application_commands
    await app_command.invoke(interaction)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\slash_core.py", line 568, in invoke
    kwargs = await resolve_param_kwargs(self.callback, inter, kwargs)
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\params.py", line 439, in resolve_param_kwargs
    kwargs[param.param_name] = await param.convert_argument(inter, kwargs[param.param_name])
  File "C:\Users\Sebastiaan\AppData\Roaming\Python\Python38\site-packages\disnake\ext\commands\params.py", line 257, in convert_argument
    raise errors.ConversionError(self.converter, e) from e
disnake.ext.commands.errors.ConversionError: (<bound method ThreadConverter.convert of <disnake.ext.commands.converter.ThreadConverter object at 0x000001DB827B6DF0>>, TypeError('expected string or bytes-like object'))

Minimal Reproducible Code

@commands.slash_command(
    options=[
        disnake.Option(
            name='thread',
            type=disnake.OptionType.channel,
            required=True,
            channel_types=[disnake.ChannelType.public_thread, disnake.ChannelType.private_thread],
        ),
    ],
)
async def test(
    self,
    interaction: disnake.ApplicationCommandInteraction,
    ticket: disnake.Thread,
) -> None:
    pass

Expected Results

The converter should not throw an error.

Actual Results

The converter throws an error.

Intents

NA

System Information

  • Python v3.8.6-final
  • disnake v2.2.0-beta
    • disnake pkg_resources: v2.2.0
  • aiohttp v3.6.3
  • system info: Windows 10 10.0.19041

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

A context menu from the example is not appearing

Summary

A context menu from the main page example doesn't appear

Reproduction Steps

Hello. I've moved to disnake today to test the context menu functionality I wasn't able to see in with Discord-interactions.

I have used my Discord token, copied the server ID in Discord and I don't see any changes in the context menu of a Discord message.
I expected to see an item like avatar, but there's none.
No exception to see why that did not happen, as well.

It doesn't matter if the decorator is located in __init__ or on_ready, it also doesn't matter if I set up a name for a command like here:

@self.user_command(name="Avatar") # optional
async def avatar(inter: disnake.UserCommandInteraction):
    # inter.target is the user you clicked on
    emb = disnake.Embed(title=f"{inter.target}'s avatar")
    emb.set_image(url=inter.target.display_avatar.url)
    await inter.response.send_message(embed=emb)

The only difference is how I construct the class, but everything else works.

Minimal Reproducible Code

GUILD_ID = 765671
DISCORD_TOKEN = 'I-am-a-bot-token'

class TestInterface(commands.Bot):
    
    def __init__(self):
        super().__init__(test_guilds=[GUILD_ID])

    async def on_ready(self):
        @self.user_command()
        async def avatar(inter):
            embed = disnake.Embed(title=str(inter.author))
            embed.set_image(url=inter.author.avatar.url)
            await inter.response.send_message(embed=embed)

def main():
    client = TestInterface()
    try:
        client.loop.run_until_complete(client.start(DISCORD_TOKEN)
    except KeyboardInterrupt:
        client.loop.run_until_complete(client.close())
    finally:
        client.loop.close()

Expected Results

I expect to be able to right-click a message, see a context menu and use an "avatar" item in it.

Actual Results

I see no new items in a message context menu.

Intents

I don't know about them, sorry

System Information

  • Python v3.8.12-final
  • disnake v2.1.2-alpha
    • disnake pkg_resources: v2.1.2
  • aiohttp v3.7.4
  • system info: Linux 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Parsed channels in slash commands do not have any permission overwrite data

Summary

It seems that permission overwrite data is missing from guild channels when used with slash commands. channel.overwrites will always return an empty dictionary.

Reproduction Steps

1). Create a slash command with a channel option
2). Check the overwrites for that channel

Minimal Reproducible Code

async def lock(
    self,
    interaction: disnake.ApplicationCommandInteraction,
    channel: disnake.TextChannel
) -> None:
    # Will always be {}
    print(channel.overwrites)

Expected Results

To receive the permission overwrites for that channel.

Actual Results

An empty dictionary at all times.

Intents

NA

System Information

  • Python v3.8.6-final
  • disnake v2.2.2-beta
    • disnake pkg_resources: v2.2.2
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19041

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

disnake error when using python 3.10

Summary

Using disnake with python 3.10 = error

Reproduction Steps

  1. code just simple bot with disnake
  2. run it with python 3.10

Minimal Reproducible Code

No response

Expected Results

Just run with no error

Actual Results

Error like this

/home/teamcloud/.local/lib/python3.10/site-packages/aiohttp/connector.py:964: RuntimeWarning: coroutine 'TCPConnector._resolve_host' was never awaited
  hosts = await asyncio.shield(self._resolve_host(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
  File "/home/teamcloud/๋ฐ”ํƒ•ํ™”๋ฉด/Cloud/Bot/main.py", line 18, in <module>
    bot.run('token')
  File "/home/teamcloud/.local/lib/python3.10/site-packages/disnake/client.py", line 834, in run
    return future.result()
  File "/home/teamcloud/.local/lib/python3.10/site-packages/disnake/client.py", line 813, in runner
    await self.start(*args, **kwargs)
  File "/home/teamcloud/.local/lib/python3.10/site-packages/disnake/client.py", line 776, in start
    await self.login(token)
  File "/home/teamcloud/.local/lib/python3.10/site-packages/disnake/client.py", line 635, in login
    data = await self.http.static_login(token.strip())
  File "/home/teamcloud/.local/lib/python3.10/site-packages/disnake/http.py", line 423, in static_login
    data = await self.request(Route("GET", "/users/@me"))
  File "/home/teamcloud/.local/lib/python3.10/site-packages/disnake/http.py", line 299, in request
    async with self.__session.request(method, url, **kwargs) as response:
  File "/home/teamcloud/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/home/teamcloud/.local/lib/python3.10/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/home/teamcloud/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/teamcloud/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/home/teamcloud/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 964, in _create_direct_connection
    hosts = await asyncio.shield(self._resolve_host(
TypeError: shield() got an unexpected keyword argument 'loop'

Intents

all

System Information

  • Python v3.10.0-final
  • disnake v2.2.1-beta
    • disnake pkg_resources: v2.2.1
  • aiohttp v3.6.3
  • system info: Linux 5.13.0-20-generic #20-Ubuntu SMP Fri Oct 15 14:21:35 UTC 2021

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Upcoming API change to interaction response attachment handling

Description

The API currently reads attachment data for interaction responses from payload["attachments"], which is also where we put attachment data. This, however, does not match the API documentation, which correctly specifies payload["data"]["attachments"]; the API side of things is subject to change soon:

We recently discovered our API had a bug where attachments wasn't nested under data - our API was reading from payload_json["attachments"] instead of payload_json["data"]["attachments"]. This isn't what we have documented, and we're considering it an implementation bug (it was introduced when I shipped multi-upload support a few weeks ago).

(full quote here: https://discord.com/channels/808030843078836254/847513235536216085/922602341151162418, private channel)

disnake is affected by this change as well:

if data is not None:
payload["data"] = data
if files:
multipart = to_multipart(payload, files)
return self.request(route, session=session, multipart=multipart, files=files)

Impact

Since API v10 isn't a thing yet and providing an attachments value is hence not required, this only affects attachment descriptions and removing existing files on edit, and not plain file upload, as far as I can tell.

Coordinating this might be difficult, since there will likely be no transitional phase where both options work, so we should have a PR and a bugfix release ready - the change will happen "shortly after we come back from our break in the new year" (also taken from the quote mentioned above), which according to an announcement in games-lab will end January 3rd.


Edit: this does not in fact affect removing files on edit, since the endpoint currently doesn't even support that (see discord/discord-api-docs#3335)

Implement commit convention in the repository.

Summary

A "commit convention" simply refers to a commit name and/or message template that is followed by all commits and PRs to the repository.

What is the feature request for?

The core library

The Problem

(The feature request is for the GitHub repository.)

Currently, our repo's commit names do not fully imply the contribution made, the section changed/added, which part of the repo is affected by it, and so on. This also causes an inconsistency in the commit history, which can later on make it difficult to search as to which commit made a specific change.

Our commit history can have an impression of our development practices and standard on a user browsing the repository, and thus can make or break what a user believes about our library.

The Ideal Solution

Having a convention/set of rules for the commits makes it easier to search for specific requirements - let it be for docs, feature additions, revert commits, or breaking changes. It also creates a discipline and uniformity that is followed by all contributors.

Implementing this can also give us an edge over competing forks. Think of it as type-safety, but for our commits. :P

My current notion is that we learn and implement from discord.js's commit convention guidelines. This includes a regex as follows:

/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,72}/;

The library will probably require tweaking this according to our directory structure, but this essentially introduces a "tag" that each commit would accordingly include, listing the section changed in parantheses. We can also alternatively refer to https://www.conventionalcommits.org/

For example, a commit to the documentation would include docs(on_message): Update parameter descriptions. This can make it simpler to search for documentation-only commits later, as well as make it easier to understand commits on the repo's frontpage (and in GitHub notifications) as to which part of the library was modified.

Additional Context

The example of discord.js's contribution guidelines is ofcourse, a suggestion and just one of the ways to do it. The intention is that we:

  1. Make it easier to read and understand what a commit/PR modifies.
  2. Make it easier to search for commits related to a certain filter.
  3. Standardize commit names and messages, for all contributors to follow.
  4. And as a result, clean up the contribution activity of the repository.

Use logger for application command sync

Summary

Use logger for application command sync

What is the feature request for?

disnake.ext.commands

The Problem

The application command sync debug logs use print statements rather than log statements, which are quite a bit worse than actual logs, as they can't be filtered, there's no timestamp etc.

The Ideal Solution

Use the library's logger.

The Current Solution

No response

Additional Context

No response

Forced `response.defer()`

Summary

The library sometimes complains about deferring an interaction

Reproduction Steps

When creating a slash command, using it would log an error in a console about the interaction already being responded to, or not responded to or something.

Minimal Reproducible Code

@disnake.slash_command(
    name="do",
    description="stuff"
)
async def doStuff(inter):
    if (var):
       await inter.response.send_message("Random error here.", ephemeral=True")
    
    await inter.response.send_message("Success")

Expected Results

The expected result is to the slash command sending "Success"

Actual Results

The slash command sends "Random error here." and logs an error in the console

Intents

dinake.Intents.all()

System Information

  • Python v3.8.9-final
  • Disnake v2.2.0-beta
    - disnake pkg-resources: v2.2.0
  • aiohttp v3.7.0.post0
  • system info: Windows 7 6.1.7601

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

A slash command in my discord bot throws an error on inter.response.defer() in less than 3 seconds, so I think this isn't lag or a discord issue, and throw Unknown Interaction.

Exception in `parse_guild_member_add`

Summary

The library seems to run into an issue (randomly) where the guild's member count is None.

Reproduction Steps

NA

Minimal Reproducible Code

NA

Expected Results

NA

Actual Results

Traceback (most recent call last):
  File "bot.py", line 112, in <module>
    libertas_support.run()
  File "bot.py", line 91, in run
    super().run(config.TOKEN)
  File "/usr/local/lib/python3.8/dist-packages/disnake/client.py", line 834, in run
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/disnake/client.py", line 813, in runner
    await self.start(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/disnake/client.py", line 777, in start
    await self.connect(reconnect=reconnect)
  File "/usr/local/lib/python3.8/dist-packages/disnake/client.py", line 674, in connect
    await self.ws.poll_event()
  File "/usr/local/lib/python3.8/dist-packages/disnake/gateway.py", line 588, in poll_event
    await self.received_message(msg.data)
  File "/usr/local/lib/python3.8/dist-packages/disnake/gateway.py", line 538, in received_message
    func(data)
  File "/usr/local/lib/python3.8/dist-packages/disnake/state.py", line 1167, in parse_guild_member_add
    guild._member_count += 1
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'

Intents

NA

System Information

  • Python v3.8.10-final
  • disnake v2.2.0-beta
    • disnake pkg_resources: v2.2.0
  • aiohttp v3.7.4.post0
  • system info: Linux 5.4.0-73-generic #โ€‹82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Failed to overwrite slash commands warning.

Summary

When creating a slash command with params, I get this error: [WARNING] Failed to overwrite global commands due to Option.__init__() got an unexpected keyword argument 'name_localizations'. It appears randomly, whether test_guilds is used or not.

Reproduction Steps

Create a simple slash command with a parameter.

When trying to run the command, it just disappears and all other slash commands too. The error seems to appear randomly.

Minimal Reproducible Code

@bot.slash_command()
async def test(
    inter: disnake.ApplicationCommandInteraction,
    text: str,
):
    await inter.response.send_message(text)

Expected Results

Slash commands to work properly.

Actual Results

Slash commands disappear.

Intents

None

System Information

  • Python v3.10.0-final
  • disnake v2.2.1-beta (PyPI version)
    • disnake pkg_resources: v2.2.1
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19042

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

I have tried reproducing the error with the GitHub version, and it seems to be working fine.

If someone could reproduce this error, I would appreciate it.

Add a shortcut for `User.name + str(User.discriminator)`

Summary

Add a shortcut for User.name + str(User.discriminator)

What is the feature request for?

The core library

The Problem

It is inconvenient to write every time you want to show user's full nickname user.name + str(user.discriminator)
I want to something like .tag attribute in discord.js

The Ideal Solution

None

The Current Solution

No response

Additional Context

No response

Stateless permanent component handlers

Summary

We need a way to handle components without being forced to use a view.

The Problem

Currently, a huge problem left over from discord.py is the enforced usage of views. Generally, most components could be handled using just information gotten from the interaction dispatched through the gateway. But instead, we are forced to use views that either timeout or make all views permanent which would however inevitably cause a memory leak.

on_message_interaction is a very good alternative but it's missing highly needed abstraction.

The Ideal Solution

Say we're working with a message that has an embed with a specific rule and buttons to get the previous (custom_id="help:prev") and next rules (custom_id="help:next") and a button to delete the message (custom_id="delete").

Pure component handlers

The simplest thing we could do is simply add our own built-in listener which dispatches other handlers.

The usage would be as follows.

def get_page(interaction: disnake.MessageInteraction) -> int:
    string = interaction.message.embeds[0].title
    return int(string.split(":")[0])

@commands.component("delete")
async def delete_message(interaction: disnake.MessageInteraction):
    await interaction.message.delete()
    await interaction.response.send_message("Deleted message", ephemeral=True)

@commands.component("help:next")
async def delete_message(interaction: disnake.MessageInteraction):
    page = get_page(interaction)
    embed = my_utils.get_rule_embed(page=page + 1)
    await interaction.response.edit_message(embed=embed)

@commands.component("help:prev")
async def delete_message(interaction: disnake.MessageInteraction):
    page = get_page(interaction)
    embed = my_utils.get_rule_embed(page=page - 1)
    await interaction.response.edit_message(embed=embed)

State in custom_id

This solution would change custom_id handling to embed encoded data (for simplicity in the form of json here). The new custom ids would be as follows (assuming the current rule page is 2): help:next#{"page":2}

The usage would be as follows.

# make this a custom class in the future maybe? More abstraction is always welcome
class PageButtonState(TypedDict):
    page: int

@commands.component("delete")
async def delete_message(interaction: disnake.MessageInteraction, state: Dict[str, Any]):
    await interaction.message.delete()
    await interaction.response.send_message("Deleted message", ephemeral=True)

@commands.component("help:next")
async def delete_message(interaction: disnake.MessageInteraction, state: PageButtonState):
    embed = my_utils.get_rule_embed(page=state["page"] + 1)
    await interaction.response.edit_message(embed=embed)

@commands.component("help:prev")
async def delete_message(interaction: disnake.MessageInteraction, state: PageButtonState):
    page = get_page(interaction)
    embed = my_utils.get_rule_embed(page=state["page"] - 1)
    await interaction.response.edit_message(embed=embed)

The Current Solution

Enforced views / permanent views / low level event handling.low-level

@listener()
async def on_message_interaction(interaction: disnake.MessageInteraction):
    custom_id = interaction.data.custom_id 

    if custom_id == "delete":
        await interaction.message.delete()
        await interaction.response.send_message("Deleted message", ephemeral=True)
    
    if custom_id not in ["help:next", "help:prev"]:
        return

    string = interaction.message.embeds[0].title
    page = int(string.split(":")[0])

    if custom_id == "help:next":
        page += 1
    if custom_id == "help:prev":
        page -= 1

    embed = my_utils.get_rule_embed(page=page)
    await interaction.response.edit_message(embed=embed)

Additional Context

This is also being discussed over in the disnake discord server.

Voice Recording

Summary

Recording Voice In A VC

What is the feature request for?

The core library

The Problem

Not being able to

The Ideal Solution

Possibly implementing a speaking state cacher in the gateway which when called if voice record is on will record voice to whatever format the user chooses

The Current Solution

No response

Additional Context

No response

Callback for 'ask' command missing 'ctx' parameter.

Summary

The confirm button example is incorrect - it does not work.

Reproduction Steps

Copy and pasted disnake/examples/views/button/confirm.py in two different files - the class and the command in two different files.
Then, I imported the file (and class). When I ran the command, I got an error.

Minimal Reproducible Code

import disnake
from disnake.ext import commands



class Confirm(disnake.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

    # When the confirm button is pressed, set the inner value to `True` and
    # stop the View from listening to more input.
    # We also send the user an ephemeral message that we're confirming their choice.
    @disnake.ui.button(label="Confirm", style=disnake.ButtonStyle.blurple)
    async def confirm(ctx: commands.Context, self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
        await interaction.response.send_message("Confirming", ephemeral=True)
        self.value = True
        self.stop()

    # This one is similar to the confirmation button except sets the inner value to `False`
    @disnake.ui.button(label="Cancel", style=disnake.ButtonStyle.grey)
    async def cancel(ctx: commands.Context, self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
        await interaction.response.send_message("Cancelling", ephemeral=True)
        self.value = False
        self.stop()


# This is in another file

    @bot.command()
    async def ask(ctx: commands.Context):
      """Asks the user a question to confirm something."""
      # We create the view and assign it to a variable so we can wait for it later.
      view = Confirm()
      await ctx.send("Do you want to continue?", view=view)
      # Wait for the View to stop listening for input...
      await view.wait()
      if view.value is None:
          print("Timed out...")
      elif view.value:
          print("Confirmed...")
      else:
          print("Cancelled...")

Expected Results

I expected the buttons to be made. However, it gave me an error.

Actual Results

I got a traceback error.

Traceback Error

Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/core.py", line 752, in _parse_arguments
    next(iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/client.py", line 505, in _run_event
    await coro(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 600, in on_message
    await self.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 597, in process_commands
    await self.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 560, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/core.py", line 921, in invoke
    await self.prepare(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/core.py", line 855, in prepare
    await self._parse_arguments(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/core.py", line 754, in _parse_arguments
    raise disnake.ClientException(
disnake.errors.ClientException: Callback for ask command is missing "ctx" parameter.

Intents

all intents

System Information

- Python v3.8.12-final
- disnake v2.2.2-beta
    - disnake pkg_resources: v2.2.2
- aiohttp v3.7.4.post0
- system info: Linux 5.11.0-1023-gcp #25~20.04.1-Ubuntu SMP Mon Nov 15 15:54:39 UTC 2021

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Disnake support for IPC routes/

Summary

This implementation will allow users to work with disnake to easily communicate with a webserver

What is the feature request for?

disnake.ext.commands

The Problem

This is based off a somewhat well used repo that got abandoned since discord.py has stopped.
Source: discord-ext-ipc

This implementation will allow the user to easily talk to the webserver and easily send information to it.
It's also much faster. I'm pretty active in the official python and whilists there are not many requests on how to make a dashboard, most people easily abandon the matter since it is not well documented and not so user friendly anymore.

I'd also like to see it as a way of being unique since not many forks have this.

Maby later even have something like an implemented Quart, Quart for discord if it really is a succes.

The Ideal Solution

This feature would make it easier for beginners to get started making Discord dashboards. This would also have routing for faster response times.

The Current Solution

This is currently not implemented inside any discord.py fork.

Additional Context

I'm also willing to make a PR or give a concept to the idea, i've not made that yet since i firstly want some more insight of wheter this will be added since it is not a small implementation. This also does not require any manipulation of the core code.

default colour for Embed

Summary

user modifiable default color for embeds

What is the feature request for?

The core library

The Problem

All embed objects default to black

The Ideal Solution

Add a class attribute, default_colour (I don't think an alias is necessary, I also don't think its possible) to disnake.Embed to provide a default colour. This will be used as the default if colour or color is not provided. Additionally, by implementing this way, a user can change the defualt colour for new embed objects during runtime.

The Current Solution

monkeypatch disnake.Embed to add a default colour in the __init__

Additional Context

No response

Embed.set_author creates an invalid embed payload if you set icon_url=None

Summary

Embed.set_author creates an invalid embed payload if you set icon_url=None

Reproduction Steps

Where author is a member with no avatar set, meaning author.avatar is None, the code

embed.set_author(
  name=author.name,
  icon_url=author.avatar
)

await send(embed=embed)

Will cause a 400 as embed payload being sent has an author with icon_url equal to the string 'None', as Embed.set_author simply do str(icon_url) if icon_url is not EmptyEmbed.

The issue here is that User.avatar can be null, and if passing in None as icon_url into Embed.set_author, the actual url will be set to the string 'None'.

One can solve this in userland by doing:

embed.set_author(
  name=author.name,
  icon_url=author.avatar or disnake.Embed.Empty
)

await send(embed=embed)

-- but surely that's not a recommended solution?

Minimal Reproducible Code

No response

Expected Results

not applicable

Actual Results

not applicable

Intents

not applicable

System Information

disnake 2.3.0

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Website layout breaks in firefox at certain resolutions

Summary

At certain resolutions, the doc site layout table of contents overlays the actual content

Reproduction Steps

  1. Navigate to https://docs.disnake.dev/en/stable/api.html (Appears in firefox 95, dark mode, and safari 15.1, light mode, presumably others)
  2. Shrink the browser window to 1270 pixels wide
  3. Observe elements clipping over each other

Minimal Reproducible Code

No response

Expected Results

Content not to overlay other elements on the page that are intended for reading

Actual Results

The sidebar overlaps the main content, either clipping the content (in dark mode), or displaying the scrollbar over the content (in light mode) impairing or preventing reading.

Intents

None

System Information

OSX 11.61
Firefox 95.0 Stable
Safari 15.1

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Make app commands accumulate similarly to text commands

Summary

Current implementation puts all invokable app commands to global dicts which isn't a correct solution.

What is the feature request for?

disnake.ext.commands

The Problem

The current implementation works, but it breaks if you try to initialize more than 1 Client instance.

The Ideal Solution

Store the app commands similarly to text commands by adding them to the Bot instance.
In case of cogs, collect all invokable slash commands on cog load and add them to the Bot instance.

The Current Solution

Is bad

Additional Context

No response

Add support for thread rate limits

Summary

A new field was added to the thread creation endpoints, which we should support

What is the feature request for?

The core library

The Problem

We're not fully covering the threads API.

Docs commit here: discord/discord-api-docs@d56be86

The Ideal Solution

Add support for the new field.

The Current Solution

No response

Additional Context

This is a fairly straight forward change, and is a good issue for a new contributor to tackle.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.