interactions-py / interactions.py

A highly extensible, easy to use, and feature complete bot framework for Discord
https://interactions-py.github.io/interactions.py/
MIT License
839 stars 184 forks source link

[BUG] Webhook cannot execute stickers #1734

Open retr0-init opened 2 months ago

retr0-init commented 2 months ago

Library Version

5.13.1

Describe the Bug

The discord webhook execution API does not contain the sticker field according to https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params.

Steps to Reproduce

  1. Create a custom sticker
  2. Execute the following code to send the sticker with webhook

Expected Results

It complains empty content sent with webhook

Minimal Reproducible Code

class TemplateCog(interactions.Extension):
    @interactions.slash_command(
        "test", description="test command", scopes=[DEV_GUILD] if DEV_GUILD else None
    )
    async def test_cmd(self, ctx: interactions.SlashContext):
        """Register as an extension command"""
        a = await ctx.channel.fetch_webhooks()
        sticker = await ctx.guild.fetch_all_custom_stickers()
        await a[0].send(username="ABCDEFG", avatar_url=ctx.author.avatar_url, stickers=sticker)

Traceback

Traceback (most recent call last):
  File "venv/lib/python3.11/site-packages/interactions/client/client.py", line 2018, in __dispatch_interaction
    response = await callback
               ^^^^^^^^^^^^^^
  File "venv/lib/python3.11/site-packages/interactions/client/client.py", line 1886, in _run_slash_command
    return await command(ctx, **ctx.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.11/site-packages/interactions/models/internal/command.py", line 132, in __call__
    await self.call_callback(self.callback, context)
  File "venv/lib/python3.11/site-packages/interactions/models/internal/application_commands.py", line 841, in call_callback
    return await self.call_with_binding(callback, ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.11/site-packages/interactions/models/internal/callback.py", line 44, in call_with_binding
    return await callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "extensions/template.py", line 26, in test_cmd
    await ctx.send(f"{ctx.channel.name}")
  File "venv/lib/python3.11/site-packages/interactions/models/discord/webhooks.py", line 255, in send
    message_data = await self._client.http.execute_webhook(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.11/site-packages/interactions/api/http/http_requests/webhooks.py", line 150, in execute_webhook
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.11/site-packages/interactions/api/http/http_client.py", line 467, in request
    await self._raise_exception(response, route, result)
  File "venv/lib/python3.11/site-packages/interactions/api/http/http_client.py", line 488, in _raise_exception
    raise HTTPException(response, response_data=result, route=route)
interactions.client.errors.HTTPException: HTTPException: 400|Bad Request || Cannot send an empty message

Checklist

Additional Information

https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params

retr0-init commented 2 months ago

I suggest the sticker parameter to be removed all together.

Additionally, the type hint of the parameter only works for list. I won't bother creating another issue as this won't be necessary as this field is deleted