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: ForumChannel default_reaction_emoji attribute #2178

Merged

Conversation

davidhozic
Copy link
Contributor

@davidhozic davidhozic commented Jul 23, 2023

Summary

This implements #2174.

Information

Added default_reaction_emoji parameter to Guild.create_forum_channel() + ForumChannel.edit() and default_reaction_emoji attribute to ForumChannel.

Example:

import discord
import secret

client = discord.Client()

@client.listen("on_ready")
async def start():
    guild = client.get_guild(863071397207212052)

    channel = await guild.create_forum_channel("Test", default_reaction_emoji="😍")
    print(f"Emoji is: {channel.default_reaction_emoji}")
    await channel.delete()

    channel = await guild.create_forum_channel("Test", default_reaction_emoji=863077925757911070)
    print(f"Emoji is: {channel.default_reaction_emoji}")
    await channel.delete()

    channel = await guild.create_forum_channel("Test", default_reaction_emoji=client.get_emoji(863077925757911070))
    print(f"Emoji is: {channel.default_reaction_emoji}")
    await channel.delete()

    channel = await guild.create_forum_channel("Test", default_reaction_emoji="<:coffee_break:863077925757911070>")
    print(f"Emoji is: {channel.default_reaction_emoji}")
    await channel.delete()

    channel = await guild.create_forum_channel("Test", default_reaction_emoji="<a:coffee_break:863077925757911070>")
    print(f"Emoji is: {channel.default_reaction_emoji}")

    await channel.edit(default_reaction_emoji=863077925757911070)
    print(f"Emoji is: {channel.default_reaction_emoji}")
    await channel.edit(default_reaction_emoji=client.get_emoji(863077925757911070))
    print(f"Emoji is: {channel.default_reaction_emoji}")
    await channel.edit(default_reaction_emoji="😙")
    print(f"Emoji is: {channel.default_reaction_emoji}")
    await channel.edit(default_reaction_emoji="<coffee_break:863077925757911070>")
    print(f"Emoji is: {channel.default_reaction_emoji}")

    await channel.delete()

client.run(secret.TOKEN)
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@davidhozic davidhozic changed the title ForumChannel default_reaction_emoji attribute feat: ForumChannel default_reaction_emoji attribute Jul 23, 2023
plun1331
plun1331 previously approved these changes Jul 23, 2023
Copy link
Member

@plun1331 plun1331 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit and create methods could accept a string representation of the emoji (<a:emoji_name:emoji_id>) for convenience, similarly to how Message.add_reaction accepts a string repr of a custom emoji (although it's implemented differently due to how the endpoint works)

other than that lgtm

@plun1331 plun1331 linked an issue Jul 23, 2023 that may be closed by this pull request
@davidhozic
Copy link
Contributor Author

edit and create methods could accept a string representation of the emoji (<a:emoji_name:emoji_id>) for convenience, similarly to how Message.add_reaction accepts a string repr of a custom emoji (although it's implemented differently due to how the endpoint works)

other than that lgtm

It does accept <a:emoji_name:emoji_id>, I'll update the docstrings to make it clearer.

Copy link
Member

@JustaSqu1d JustaSqu1d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix documentation formatting

See here, for example.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Lala Sabathil <aiko@aitsys.dev>
Copy link
Member

@JustaSqu1d JustaSqu1d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidhozic
Copy link
Contributor Author

davidhozic commented Jul 25, 2023

What does this do

https://github.com/davidhozic/pycord/blob/feat/default_forum_reaction/discord/abc.py#L511-L514

It checks if the key exists and assigns value - if parameter was given to the edit method. If it doesn't exist, it will raise an Exception and not execute the else statement. I wrote it in the style everything is written, one could also use a normal

if (var := sth.get(key)) is not None: ...

Signed-off-by: David Hozic <davidhozic@gmail.com>
Signed-off-by: plun1331 <plun1331@gmail.com>
@plun1331 plun1331 merged commit af97fea into Pycord-Development:master Dec 14, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set default_reaction_emoji in a ForumChannel
5 participants