interactions.py
interactions.py copied to clipboard
feat: GuildForum supports webhook
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
- Create a Forum channel if there is not one.
- 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")
- 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-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