interactions.py
interactions.py copied to clipboard
feat: add `thread_name` field in the webhook field
Pull Request Type
- [x] Feature addition
- [ ] Bugfix
- [ ] Documentation update
- [ ] Code refactor
- [ ] Tests improvement
- [ ] CI/CD pipeline enhancement
- [ ] Other: [Replace with a description]
Description
This enables the API to create thread in forum and media channels.
Changes
- Added
thread_namefield to theapi.http.http_requests.webhook.WebhookRequests.execute_webhookmethod. - Added
thread_namefield to themodels.discord.webhook.Webhook.sendmethod - add exclusive check between the
thread_nameandthread
Related Issues
#1721
Test Scenarios
@interactions.slash_command(
"test1", description="test channel command", scopes=[DEV_GUILD] if DEV_GUILD else None
)
@interactions.slash_option(
name="channel",
description="Channel",
opt_type=interactions.OptionType.CHANNEL,
required=True
)
async def test_cmd(self, ctx: interactions.SlashContext, channel: interactions.GuildForum):
"""Register as an extension command"""
await ctx.send(f"Test Create a post in channel {channel.mention} with webhook")
wbs: list[interactions.Webhook] = await channel.fetch_webhooks()
if len(wbs) > 0:
msg: interactions.Message = await wbs[0].send("test content", embed=interactions.Embed(
title="Embed title",
description="Embed desc"
), wait=True, thread_name="Post Title")
await ctx.send(f"Created {msg.jump_url}")
Python Compatibility
- [ ] I've ensured my code works on Python
3.10.x - [x] I've ensured my code works on Python
3.11.x
Checklist
- [x] I've run the
pre-commitcode linter over all edited files - [x] I've tested my changes on supported Python versions
- [x] I've added tests for my code, if applicable
- [x] I've updated / added documentation, where applicable