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

Implement spoiler functionality #245

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Conversation

FoxxMD
Copy link
Contributor

@FoxxMD FoxxMD commented Feb 28, 2024

I wasn't originally planning to do this but a user in my server forced my hand after generating some truly heinous images. 🥲

  • channel-wide spoiler option available via /settings
  • per /draw option
  • force spoiler on role, option available via /settings

Closes #168


In /settings it shows formatted role name when present

image

Can use remove_spoiler_role boolean in settings to entirely remove role in which case it displays spoiler_role - None

image

The spoiler option in /settings is a default for the channel that can be overridden using the spoiler option in the /draw command

image

Finally, the entire channel can be forced to use spoilers if the spoiler_role is set to @everyone

image

* channel-wide spoiler option available via /settings
* per /draw option
* force spoiler on role, option available via /settings
@sebaxakerhtc
Copy link
Contributor

sebaxakerhtc commented Feb 29, 2024

It's a really nice PR!
Copied it to my repo, thank you!

@FoxxMD
There's a PR about Live preview
Can you help with Live preview too?

Because if it will be merged - we will need to anyhow hide it.

I try but something wrong here

        with contextlib.ExitStack() as stack:
            buffer = stack.enter_context(io.BytesIO())
            image.save(buffer, 'PNG')
            buffer.seek(0)
            file = discord.File(fp=buffer, filename=f'{queue_object.seed}.png')

How to add your part right way?

            if queue_object.spoiler:
                filename=f'SPOILER_{queue_object.seed}.png'

I tried this way

        with contextlib.ExitStack() as stack:
            buffer = stack.enter_context(io.BytesIO())
            image.save(buffer, 'PNG')
            buffer.seek(0)
            filename=f'{queue_object.seed}.png'
            if queue_object.spoiler:
                filename=f'SPOILER_{queue_object.seed}.png'
            file = discord.File(fp=buffer, filename)

But it gives me SyntaxError: positional argument follows keyword argument

Upd. Solved this way:

        with contextlib.ExitStack() as stack:
            buffer = stack.enter_context(io.BytesIO())
            image.save(buffer, 'PNG')
            buffer.seek(0)
            filename=f'{queue_object.seed}.png'
            if queue_object.spoiler:
                filename=f'SPOILER_{queue_object.seed}.png'
            fp=buffer
            file = discord.File(fp, filename)

Working like a charm!

@Kilvoctu
Copy link
Owner

Heya, looks nice. Thanks for the PR 👍

@Kilvoctu Kilvoctu merged commit 539f2d9 into Kilvoctu:main Feb 29, 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.

4 participants