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

feat: GuildForum supports webhook

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

Pull Request Type

  • [x] Feature addition
  • [ ] Bugfix
  • [ ] Documentation update
  • [ ] Code refactor
  • [ ] Tests improvement
  • [ ] CI/CD pipeline enhancement
  • [ ] Other: [Replace with a description]

Description

Webhook support for Forum channel itself is missing. i.e.:

channel: GuildForum = ctx.guild.get_channel(FORUM_CHANNEL_ID)
await channel.create_webhook("test")

Changes

Class GuildForum now also inherits class WebhookMixin.

Related Issues

N/A

Test Scenarios

  1. Create a Forum channel if there is not one.
  2. Register a function like below:
@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 webhook in channel {channel.mention}")
    await channel.create_webhook(f"{channel.name}WBT")
  1. Run this command in guild and you can see a webhook is created.

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 20:07 retr0-init