Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial webhook send with components raises invalid argument #52

Open
3 tasks done
juststephen opened this issue May 2, 2022 · 0 comments
Open
3 tasks done

Partial webhook send with components raises invalid argument #52

juststephen opened this issue May 2, 2022 · 0 comments

Comments

@juststephen
Copy link
Contributor

Summary

Webhook send should support components when the webhook is partial and owned by the bot

Reproduction Steps

The bot created a webhook in a channel, the URL of that webhook was then used to create a new connection to send a message with components (i.e. buttons). However due to a check in the send method, the components are raised as an invalid argument.
When removing these checks at lines:

if components is not MISSING:
if isinstance(self._state, _WebhookState):
raise InvalidArgument('Webhook components require an associated state with the webhook')

The sending works and the components work as intended. This was only done for the async webhook version.

Minimal Reproducible Code

import aiohttp
import discord
from discord.ext.commands import Bot
from discord.ui import Button, MessageComponents

token = ''
webhook_url = ''

client = Bot(
    command_prefix='None',
    help_command=None
)

# Components
buttons = MessageComponents.add_buttons_with_rows(
    Button(
        label='Novus Documentation',
        style=discord.ButtonStyle.link,
        url='https://novus.readthedocs.io/en/latest/'
    )
)

@client.event
async def on_ready():
    # Creating session
    async with aiohttp.ClientSession() as session:
        # Creating webhook
        webhook = discord.Webhook.from_url(
            webhook_url,
            session=session
        )

        # Sending notification
        await webhook.send(
            'Message',
            components=buttons,
        )

client.run(token)

Expected Results

The method should not raise an invalid argument exception.

Actual Results

The method raises an invalid argument exception.

Intents

None

System Information

  • Python v3.10.2-final
  • Novus v0.0.5-alpha
    • Novus pkg_resources: v0.0.7
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19044

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant