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
Additional Context
No response
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:
Novus/discord/webhook/async_.py
Lines 1305 to 1307 in 8a625e0
The sending works and the components work as intended. This was only done for the async webhook version.
Minimal Reproducible Code
Expected Results
The method should not raise an invalid argument exception.
Actual Results
The method raises an invalid argument exception.
Intents
None
System Information
Checklist
Additional Context
No response