Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add webhook message functions #1689

Merged

Conversation

Lacosst0
Copy link
Contributor

@Lacosst0 Lacosst0 commented Jun 3, 2024

Pull Request Type

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

Description

Adds Webhook.get_message() and Webhook.delete_message()
delete_message has delay parameter like Message.delete()
get_message returns None if message not found and named like http.get_webhook_message

Changes

  • Added Webhook.get_message()
  • Added Webhook.delete_message()

Related Issues

Test Scenarios

@slash_command()
async def test(self, ctx: SlashContext):
    webhook = await ctx.channel.create_webhook("Test")
    msg = await webhook.send("Test passed!", wait=True)

    webhook_message = await webhook.get_message(msg.id)
    print(webhook_message.content)

    await webhook.delete_message(msg.id, delay=5)
    # Test delay in delete_message
    webhook_message = await webhook.get_message(msg.id)
    print(webhook_message.content)

    await asyncio.sleep(5)
    webhook_message = await webhook.get_message(msg.id)
    if webhook_message is None:
        print("Test passed!")

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x
  • I've ensured my code works on Python 3.12.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

interactions/models/discord/webhooks.py Outdated Show resolved Hide resolved
@Lacosst0 Lacosst0 requested a review from AstreaTSS June 3, 2024 17:20
@AstreaTSS AstreaTSS dismissed their stale review June 3, 2024 19:15

Requested change happened, but unable to properly review.

@silasary silasary merged commit a96a834 into interactions-py:unstable Jun 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants