interactions.py icon indicating copy to clipboard operation
interactions.py copied to clipboard

feat: add `thread_name` field in the webhook field

Open retr0-init opened this issue 1 year ago • 4 comments

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_name field to the api.http.http_requests.webhook.WebhookRequests.execute_webhook method.
  • Added thread_name field to the models.discord.webhook.Webhook.send method
  • add exclusive check between the thread_name and thread

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-commit code 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

retr0-init avatar Jul 27 '24 21:07 retr0-init