[Trivia] Commands for managing custom trivia lists #3420

Merged
Stonedestroyer merged 48 commits from trivia-upload into V3/develop 2020-03-21 16:30:34 +01:00
Stonedestroyer commented 2020-01-20 09:25:23 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Trivia upload command.

This is a draft PR so I can take ideas or if I am going in the wrong direction.

Resolves #3307.

  • Upload command
  • Delete command
  • Listing
### Type - [ ] Bugfix - [ ] Enhancement - [X] New feature ### Description of the changes Trivia upload command. This is a draft PR so I can take ideas or if I am going in the wrong direction. Resolves #3307. - [X] Upload command - [x] Delete command - [X] Listing
palmtree5 (Migrated from github.com) reviewed 2020-01-20 09:25:23 +01:00
Twentysix26 (Migrated from github.com) reviewed 2020-01-20 09:25:23 +01:00
Tobotimus (Migrated from github.com) reviewed 2020-01-20 09:25:23 +01:00
Stonedestroyer commented 2020-01-20 10:54:20 +01:00 (Migrated from github.com)

How do we want to support duplicate lists?

I am thinking if a duplicate list is uploaded to either ask to overwrite or skip?

And also if a list has the same name as a baselist warn user and gracefully error?

Does these two ideas sond good.

How do we want to support duplicate lists? I am thinking if a duplicate list is uploaded to either ask to overwrite or skip? And also if a list has the same name as a baselist warn user and gracefully error? Does these two ideas sond good.
Drapersniper commented 2020-01-20 11:55:48 +01:00 (Migrated from github.com)

I would personally say if a playlist with the same name we prompt the user to override or skip. or simply silently fail and at the end of the command give a report to the user with failed list and reason it failed.

I would personally say if a playlist with the same name we prompt the user to override or skip. or simply silently fail and at the end of the command give a report to the user with failed list and reason it failed.
Stonedestroyer commented 2020-01-20 12:10:29 +01:00 (Migrated from github.com)
  • I am looking into adding maybe if you don't supply a file to ask you to add a file into that message or cancel but not sure. This should be done and work fairly well.

Do we need a delete command?

- [X] I am looking into adding maybe if you don't supply a file to ask you to add a file into that message or cancel but not sure. This should be done and work fairly well. Do we need a delete command?
Stonedestroyer commented 2020-01-20 12:32:00 +01:00 (Migrated from github.com)

Part 2 will include deletion and also a way to see what is a custom list.
Part 3 which is later will include interactive generator. #3422

Part 2 will include deletion and also a way to see what is a custom list. Part 3 which is later will include interactive generator. #3422
Stonedestroyer commented 2020-01-20 14:42:44 +01:00 (Migrated from github.com)

This is WIP.

This is WIP.
mikeshardmind (Migrated from github.com) reviewed 2020-01-20 15:53:15 +01:00
mikeshardmind (Migrated from github.com) commented 2020-01-20 15:53:15 +01:00

just something I noticed, don't know if the PR is intended to be ready yet. You've already saved this to a BytesIO object, just write the object, dont download from discord again

just something I noticed, don't know if the PR is intended to be ready yet. You've already saved this to a BytesIO object, just write the object, dont download from discord again
Stonedestroyer (Migrated from github.com) reviewed 2020-01-20 18:14:16 +01:00
Stonedestroyer (Migrated from github.com) commented 2020-01-20 18:14:15 +01:00

Thank you, changed it.

Thank you, changed it.
Stonedestroyer commented 2020-01-20 18:14:30 +01:00 (Migrated from github.com)

This is pretty much done and ready to go for review.

This is pretty much done and ready to go for review.
Jackenmen (Migrated from github.com) requested changes 2020-03-17 14:00:41 +01:00
Jackenmen (Migrated from github.com) left a comment

Overall, a good PR, there are few things that need changing but nothing major.

Overall, a good PR, there are few things that need changing but nothing major.
@ -186,0 +251,4 @@
except yaml.error.YAMLError:
await ctx.send(
_("There was an error parsing the trivia list. See logs for more info.")
)
Jackenmen (Migrated from github.com) commented 2020-03-17 12:47:32 +01:00

While I get why it's useful for bot owner to know which lists are custom (since these are the only ones owner can remove), I don't think it really should be shown to users like this. Maybe there should be a separate command for listing uploaded (custom) lists?

While I get why it's useful for bot owner to know which lists are custom (since these are the only ones owner can remove), I don't think it really should be shown to users like this. Maybe there should be a separate command for listing uploaded (custom) lists?
Jackenmen (Migrated from github.com) commented 2020-03-17 12:58:40 +01:00

I think it might be worth sending the syntax error that happened during parsing of the YAML file (based on how permissions cog does it):

        except yaml.MarkedYAMLError as exc:
            await ctx.send(_("Invalid syntax: ") + str(exc))

And logging here is not gonna really be needed then as all the needed info is gonna already be in the sent message.

I think it might be worth sending the syntax error that happened during parsing of the YAML file (based on how permissions cog does it): ```suggestion except yaml.MarkedYAMLError as exc: await ctx.send(_("Invalid syntax: ") + str(exc)) ``` And logging here is not gonna really be needed then as all the needed info is gonna already be in the sent message.
Jackenmen (Migrated from github.com) commented 2020-03-17 13:03:09 +01:00

I propose using a timeout here, maybe 30 seconds?

I propose using a timeout here, maybe 30 seconds?
Jackenmen (Migrated from github.com) commented 2020-03-17 13:12:42 +01:00

It would be better to check against list of subcommands programatically than hardcoding those names:

        if filename in self.trivia.all_commands:
It would be better to check against list of subcommands programatically than hardcoding those names: ```suggestion if filename in self.trivia.all_commands: ```
Jackenmen (Migrated from github.com) commented 2020-03-17 13:14:52 +01:00

This check should probably happen before we try to download the attachment.

This check should probably happen *before* we try to download the attachment.
Jackenmen (Migrated from github.com) commented 2020-03-17 13:17:32 +01:00

String has to be formatted after translation.

                    _(
                        "{filename} is a reserved trivia name and cannot be replaced.\n"
                        "Choose another name"
                    ).format(filename=filename)
String has to be formatted after translation. ```suggestion _( "{filename} is a reserved trivia name and cannot be replaced.\n" "Choose another name" ).format(filename=filename) ```
Jackenmen (Migrated from github.com) commented 2020-03-17 13:18:28 +01:00

String has to be formatted after translation.

                    _(
                        "{filename} already exists. Do you wish to overwrite?"
                    ).format(filename=filename)
String has to be formatted after translation. ```suggestion _( "{filename} already exists. Do you wish to overwrite?" ).format(filename=filename) ```
Jackenmen (Migrated from github.com) commented 2020-03-17 13:19:41 +01:00

This string has to be wrapped in _() for translations.

            await ctx.send(_("Saved Trivia list as {filename}").format(filename=filename))
This string has to be wrapped in `_()` for translations. ```suggestion await ctx.send(_("Saved Trivia list as {filename}").format(filename=filename)) ```
Jackenmen (Migrated from github.com) commented 2020-03-17 13:53:06 +01:00

I think it might be friendlier to use reactions here, but it's up to you. Whatever you choose, use a timeout here as well.

I think it might be friendlier to use reactions here, but it's up to you. Whatever you choose, use a timeout here as well.
Jackenmen (Migrated from github.com) commented 2020-03-17 13:55:22 +01:00

I don't think logging is really needed here.

I don't think logging is really needed here.
Jackenmen (Migrated from github.com) commented 2020-03-17 13:59:38 +01:00

Nitpick, I think using only bool type for this variable makes more sense here

        basefileexists = False
Nitpick, I think using only bool type for this variable makes more sense here ```suggestion basefileexists = False ```
Stonedestroyer (Migrated from github.com) reviewed 2020-03-21 14:43:09 +01:00
@ -186,0 +251,4 @@
except yaml.error.YAMLError:
await ctx.send(
_("There was an error parsing the trivia list. See logs for more info.")
)
Stonedestroyer (Migrated from github.com) commented 2020-03-21 14:43:09 +01:00

Adding custom command trivialist while list shows all of it.

Adding custom command trivialist while list shows all of it.
Jackenmen (Migrated from github.com) reviewed 2020-03-21 14:49:15 +01:00
Jackenmen (Migrated from github.com) commented 2020-03-21 14:49:14 +01:00
                _(
                    "{filename} is a reserved trivia name and cannot be replaced.\n"
                    "Choose another name"
                ).format(filename=filename)
```suggestion _( "{filename} is a reserved trivia name and cannot be replaced.\n" "Choose another name" ).format(filename=filename) ```
Jackenmen (Migrated from github.com) requested changes 2020-03-21 16:20:31 +01:00
@ -186,0 +214,4 @@
title=_("Uploaded trivia lists"),
colour=await ctx.embed_colour(),
description=", ".join(sorted(personal_lists)),
)
Jackenmen (Migrated from github.com) commented 2020-03-21 16:20:28 +01:00

0 lists should be special-cased:
image

0 lists should be special-cased: ![image](https://user-images.githubusercontent.com/6032823/77229758-df5b0100-6b8f-11ea-9493-3a735705d83b.png)
Jackenmen (Migrated from github.com) commented 2020-03-21 16:19:54 +01:00
            overwrite_message_object: discord.Message = await ctx.send(overwrite_message)
```suggestion overwrite_message_object: discord.Message = await ctx.send(overwrite_message) ```
Jackenmen (Migrated from github.com) reviewed 2020-03-21 16:26:03 +01:00
@ -186,0 +219,4 @@
else:
msg = box(
bold(_("Uploaded trivia lists")) + "\n\n" + ", ".join(sorted(personal_lists))
)
Jackenmen (Migrated from github.com) commented 2020-03-21 16:26:02 +01:00

You have to return at the end of this if

You have to return at the end of this `if`
Jackenmen (Migrated from github.com) approved these changes 2020-03-21 16:29:12 +01:00
Jackenmen (Migrated from github.com) left a comment

LGTM, thanks for the PR!

LGTM, thanks for the PR!
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!3420
No description provided.