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

Custom help command implementation #187

Merged
merged 30 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9797cd9
Added a custom handler for the help command
Aug 30, 2021
6a2d428
Added docstrings and commenting
Aug 30, 2021
9375dbc
Moved MusicCog help strings into user_strings.toml
Aug 31, 2021
277db73
Added support for user_string defined help strings as well as still s…
Aug 31, 2021
ab603c0
Added missing help string for musicadmin command group
Aug 31, 2021
23b03eb
Replace hyphens with underscores for the help string dict key
Aug 31, 2021
26c2e73
Fixed angled brackets not being escaped in README
Aug 31, 2021
0343d0b
Moved PingableRolesCog help strings into user_strings.toml
Aug 31, 2021
47eb634
Added hints for pingme command groups
Aug 31, 2021
45ba992
Changed VoicemasterCog terminology to use parent/child terminology ov…
Aug 31, 2021
efdc1d1
Fixed missing newlines for list options in Voicemaster README section
Aug 31, 2021
4fe7baf
Moved VoicemasterCog help strings into user_strings.toml
Aug 31, 2021
b702790
Renamed clear_messages command
Aug 31, 2021
781c2b4
Added missing README documentation for the version command
Aug 31, 2021
2a02662
Fixed incorrect command name in VoicemasterCog
Aug 31, 2021
152595b
Fixed an issue where checks for commands were not properly restored a…
Aug 31, 2021
a168d5a
Added support for hiding hidden commands from non-administrators
Aug 31, 2021
4f39da3
Made dev-only commands hidden
Aug 31, 2021
7a666c7
Moved help strings for AdminCog.py to user_strings.toml
Aug 31, 2021
d06bfc4
Fixed missing newlines for the log channel section in the README
Aug 31, 2021
20a74c7
Moved help strings for LogChannelCog into user_strings.toml
Aug 31, 2021
824b423
Moved help strings for TwitterCog into user_strings.toml
Aug 31, 2021
96f9af4
Fixed missing newlines for Default Roles section in README
Aug 31, 2021
5b3c680
Moved help strings for DefaultRoleCog to user_strings.toml
Aug 31, 2021
825049c
Moved help strings for EventCategoriesCog to user_strings.toml
Aug 31, 2021
f3d06c7
Moved help strings for RoleReactCog to user_strings.toml
Aug 31, 2021
620de8d
Moved help strings for VotingCog to user_strings.toml
Aug 31, 2021
501ee86
Fixed missing await in send_cog_help
Aug 31, 2021
8f58133
Moved help strings for TwitchCog to user_strings.toml
Aug 31, 2021
1719919
Fixed outdated README for Twitch Cog section
Aug 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved PingableRolesCog help strings into user_strings.toml
  • Loading branch information
Fluxticks committed Aug 31, 2021
commit 0343d0b32822888256dbead2a4b3ac2fcbf8ca07
92 changes: 17 additions & 75 deletions src/esportsbot/cogs/PingableRolesCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,15 @@ async def get_guild_in_settings(self, context):
return None
return db_item

@commands.group(name="pingme", help="Get and create custom roles with ping cooldown timers.", invoke_without_command=True)
@commands.group(name="pingme", invoke_without_command=True)
async def ping_me(self, context: commands.Context):
"""
The command group used to make all commands sub-commands .
:param context: The context of the command .
"""
pass

@ping_me.group(name="settings", help="Set default values for this server.")
@ping_me.group(name="settings")
@commands.has_permissions(administrator=True)
async def ping_me_settings(self, context: commands.Context):
"""
Expand All @@ -592,7 +592,7 @@ async def ping_me_settings(self, context: commands.Context):
"""
pass

@ping_me_settings.command(name="get-settings", help="Returns an embed of the current default settings for the server.")
@ping_me_settings.command(name="get-settings")
async def get_guild_settings(self, context: commands.Context):
"""
Returns a list of the current settings in a guild .
Expand Down Expand Up @@ -633,10 +633,7 @@ async def get_guild_settings(self, context: commands.Context):
embed.add_field(name=f"• Role Cooldown Seconds: {guild_settings.get('role_cooldown')}", value="​", inline=False)
await context.send(embed=embed)

@ping_me_settings.command(
name="default-settings",
help="Resets all settings for this guild to the bot-defined defaults defined in the .env file."
)
@ping_me_settings.command(name="default-settings")
async def default_settings(self, context: commands.Context):
"""
Sets the settings for a guild back to the default settings .
Expand Down Expand Up @@ -674,12 +671,7 @@ async def default_settings(self, context: commands.Context):
self.logger.info(f"{context.guild.name} has had its pingable settings set back to defaults!")
await context.reply(self.user_strings["default_settings_set"])

@ping_me_settings.command(
name="poll-length",
usage="<poll length in seconds>",
help="Sets the default poll length to the given time in seconds. "
"Poll lengths can still be overridden by giving the poll length in the `create-role` command!"
)
@ping_me_settings.command(name="poll-length")
async def set_poll_length(self, context: commands.Context, poll_length: int):
"""
Sets the default poll length setting for a guild to the given value .
Expand All @@ -697,11 +689,7 @@ async def set_poll_length(self, context: commands.Context, poll_length: int):
await context.reply(self.user_strings["set_poll_length"].format(poll_length=poll_length))
self.logger.info(f"Set {context.guild.name} default poll length to {poll_length}s")

@ping_me_settings.command(
name="poll-threshold",
usage="<number of votes threshold>",
help="Sets the number of votes required in a poll for the role to be created."
)
@ping_me_settings.command(name="poll-threshold")
async def set_poll_threshold(self, context: commands.Context, vote_threshold: int):
"""
Sets the poll vote threshold setting for a guild to the given value .
Expand All @@ -719,11 +707,7 @@ async def set_poll_threshold(self, context: commands.Context, vote_threshold: in
await context.reply(self.user_strings["set_poll_threshold"].format(vote_threshold=vote_threshold))
self.logger.info(f"Set {context.guild.name} poll threshold to {vote_threshold} votes")

@ping_me_settings.command(
name="ping-cooldown",
usage="<cooldown in seconds>",
help="Sets the default ping cooldown for any pingable role created with this cog."
)
@ping_me_settings.command(name="ping-cooldown")
async def set_role_cooldown(self, context: commands.Context, role_cooldown: int):
"""
Sets the default role ping cooldown setting for a guild to the given value .
Expand All @@ -747,11 +731,7 @@ async def set_role_cooldown(self, context: commands.Context, role_cooldown: int)
await context.reply(self.user_strings["set_role_cooldown"].format(cooldown=role_cooldown))
self.logger.info(f"Set {context.guild.name} pingable role cooldown to {role_cooldown}s")

@ping_me_settings.command(
name="poll-emoji",
usage="<emoji>",
help="Sets the emoji to be used when creating a poll to vote in."
)
@ping_me_settings.command(name="poll-emoji")
async def set_poll_emoji(self, context: commands.Context, poll_emoji: MultiEmoji):
"""
Sets the poll voting emoji for a guild to the given emoji .
Expand All @@ -774,11 +754,7 @@ async def set_poll_emoji(self, context: commands.Context, poll_emoji: MultiEmoji
await context.reply(self.user_strings["set_poll_emoji"].format(emoji=poll_emoji.discord_emoji))
self.logger.info(f"Set {context.guild.name} poll emoji to {poll_emoji.name}")

@ping_me_settings.command(
name="role-emoji",
usage="<emoji>",
help="Sets the default emoji to be used in the role reaction menu for the pingable role once it has been created."
)
@ping_me_settings.command(name="role-emoji")
async def set_role_emoji(self, context: commands.Context, role_emoji: MultiEmoji):
"""
Sets the default role reaction emoji for a guild to the given emoji .
Expand All @@ -796,12 +772,7 @@ async def set_role_emoji(self, context: commands.Context, role_emoji: MultiEmoji
await context.reply(self.user_strings["set_role_emoji"].format(emoji=role_emoji.discord_emoji))
self.logger.info(f"Set {context.guild.name} role emoji to {role_emoji.name}")

@ping_me.command(
name="create-role",
usage="<role name> [Optional: poll length in seconds]",
help="Creates a new poll to create a role if the number of votes has surpassed the server's threshold after the"
" poll length has passed."
)
@ping_me.command(name="create-role")
async def create_role(self, context: commands.Context, role_name: str, poll_length: int = None):
"""
Creates a new role poll for a role with the name given . If no poll length is given, the guild default
Expand Down Expand Up @@ -840,11 +811,7 @@ async def create_role(self, context: commands.Context, role_name: str, poll_leng
await context.reply(self.user_strings["create_success"])
self.logger.info(f"Created a new poll for a pingable role with the name {role_name} in guild {context.guild.name}")

@ping_me.command(
name="delete-role",
usage="<one or many role mentions>",
help="Deletes the mentioned roles from the server. Cannot be used to delete non-pingable roles."
)
@ping_me.command(name="delete-role")
@commands.has_permissions(administrator=True)
async def delete_role(self, context: commands.Context):
"""
Expand Down Expand Up @@ -873,11 +840,7 @@ async def delete_role(self, context: commands.Context):
await context.reply(self.user_strings["role_delete_success"].format(deleted_roles=deleted_string))
self.logger.info(f"Deleted pingable roles: {deleted_string} in guild {context.guild.name}")

@ping_me.command(
name="convert-role",
usage="<One or many role mentions>",
help="Converts the mentioned roles into pingable roles and creates their reaction menus."
)
@ping_me.command(name="convert-role")
@commands.has_permissions(administrator=True)
async def convert_role(self, context: commands.Context):
"""
Expand Down Expand Up @@ -906,11 +869,7 @@ async def convert_role(self, context: commands.Context):
await context.reply(self.user_strings["role_convert_success"].format(converted_roles=converted_string))
self.logger.info(f"Converted pingable roles: {converted_string} in guild {context.guild.name}")

@ping_me.command(
name="convert-pingable",
usage="<one or many role mentions>",
help="Converts the mentioned roles from pingable roles into normal roles and deletes their reaction menus."
)
@ping_me.command(name="convert-pingable")
@commands.has_permissions(administrator=True)
async def convert_pingable(self, context: commands.Context):
"""
Expand Down Expand Up @@ -940,11 +899,7 @@ async def convert_pingable(self, context: commands.Context):
await context.reply(self.user_strings["pingable_convert_success"].format(converted_roles=converted_string))
self.logger.info(f"Converted pingable roles: {converted_string} in guild {context.guild.name}")

@ping_me.command(
name="role-cooldown",
usage="<role mention | role ID> <cooldown in seconds>",
help="Sets the ping cooldown for a specific role which overrides the server default for that role."
)
@ping_me.command(name="role-cooldown")
@commands.has_permissions(administrator=True)
async def change_pingable_role_cooldown(self, context: commands.Context, pingable_role: Role, cooldown_seconds: int):
"""
Expand Down Expand Up @@ -976,11 +931,7 @@ async def change_pingable_role_cooldown(self, context: commands.Context, pingabl
seconds=cooldown_seconds)
)

@ping_me.command(
name="role-emoji",
usage="<role mention | role ID> <emoji>",
help="Sets the emoji to use in the reaction menu for the given role."
)
@ping_me.command(name="role-emoji")
@commands.has_permissions(administrator=True)
async def change_pingable_role_emoji(self, context: commands.Context, pingable_role: Role, role_emoji: MultiEmoji):
"""
Expand All @@ -1003,11 +954,7 @@ async def change_pingable_role_emoji(self, context: commands.Context, pingable_r
emoji=role_emoji.discord_emoji)
)

@ping_me.command(
name="disable-role",
usage="<one or many role mentions>",
help="Disables the roles mentioned from being mentioned by non-administrators and disables their reaction menus."
)
@ping_me.command(name="disable-role")
@commands.has_permissions(administrator=True)
async def disable_pingable_role(self, context: commands.Context):
"""
Expand All @@ -1032,12 +979,7 @@ async def disable_pingable_role(self, context: commands.Context):
disabled_string = str(disabled_roles).replace("[", "").replace("]", "")
await context.reply(self.user_strings["roles_disabled"].format(disabled_roles=disabled_string))

@ping_me.command(
name="enable-role",
usage="<one or many role mentions>",
help="Enabled the roles mentioned to be mentioned by non-administrators and "
"allows their reaction menus to be reacted to."
)
@ping_me.command(name="enable-role")
@commands.has_permissions(administrator=True)
async def enabled_pingable_roles(self, context: commands.Context):
"""
Expand Down
95 changes: 95 additions & 0 deletions src/esportsbot/user_strings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,101 @@ help_string = "Unlinks the currently set music channel from being the music chan
description = "This will just stop the channel from processing song requests, the channel will not be deleted with this command and will just be a regular text channel."
readme_url = "https://github.com/FragSoc/esports-bot#musicadmin-remove"

[help.pingme]
help_string = "This is a command group used to create custom roles that have ping cooldown timers."
readme_url = "https://github.com/FragSoc/esports-bot#pingable-roles"

[help.pingme_settings]
help_string = "This is a command group used to manage the default settings for pingable roles in this server. These commands require the `administrator` permission in this server."
readme_url = "https://github.com/FragSoc/esports-bot#pingable-roles"

[help.pingme_settings_get_settings]
help_string = "Shows the current settings for this server."
description = "The settings shown are the default settings applied to new roles when they are created. Polls and Roles can have some of their settings overridden with other pingme settings commands."
readme_url = "https://github.com/FragSoc/esports-bot#pingme-settings-get-settings"

[help.pingme_settings_default_settings]
help_string = "Resets all settings for this server to the bot-defined defaults."
readme_url = "https://github.com/FragSoc/esports-bot#pingme-settings-default-settings"

[help.pingme_settings_poll_length]
help_string = "Sets the default poll length to the given time in seconds."
description = "This is the default length used in a poll if when no poll length is given when creating a poll."
usage = "<poll length in seconds>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-settings-poll-length-poll-length-in-seconds"

[help.pingme_settings_poll_threshold]
help_string = "Sets the number of votes required for a poll to pass."
description = "If a poll passes or equals the value set here, when finished a pingable role will be created with the default settings and all users who voted will be granted the new role."
usage = "<number of votes required>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-settings-poll-threshold-number-of-votes-threshold"

[help.pingme_settings_ping_cooldown]
help_string = "Sets the default ping cooldown for new pingable roles."
description = "This cooldown is the time in which the role cannot be mentioned again. This ping cooldown will only apply to new roles created, and will not affect roles previously created with the default ping cooldown."
usage = "<ping cooldown in seconds>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-settings-ping-cooldown-cooldown-in-seconds"

[help.pingme_settings_poll_emoji]
help_string = "Sets the emoji used in voting polls."
description = "This sets the emoji that users use to vote on if they want a new pingable role. This will not affect any already running polls."
usage = "<emoji>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-settings-poll-emoji-emoji"

[help.pingme_settings_role_emoji]
help_string = "Sets the emoji used in the role reaction menu."
description = "Once a role is created it will also create a role reaction menu so that users who didn't vote but want the role can get the role. This command sets the emoji for the reaction used to get or remove the role from a user. This will not affect any already existing role reaction menus."
usage = "<emoji>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-settings-role-emoji-emoji"

[help.pingme_create_role]
help_string = "Creates a new poll to create a new role."
description = "Creates a new poll for users to vote on. If the number of votes surpasses the servers defined vote threshold, a new role is created with the name given in this command. The role will be given to all users who voted and a reaction menu will be created so users who have the role can remove it and users who want the role can receive it."
usage="<role name> [Optional: poll length in seconds]"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-create-role-role-name-optional-poll-length-in-seconds"

[help.pingme_delete_role]
help_string = "Deletes the roles mentioned."
description = "Completely deletes all roles mentioned, as long as the roles mentioned are pingable roles. This command cannot delete roles that are not pingable roles."
usage = "<one or many role mentions>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-delete-role-one-or-many-role-mentions"

[help.pingme_convert_role]
help_string = "Converts a mentioned role into a pingable one."
description = "This creates the reaction menu for the role and makes it a role that has a ping cooldown, which by default is the server default ping cooldown timer."
usage = "<one or many role mentions>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-convert-role-one-or-many-role-mentions"

[help.pingme_convert_pingable]
help_string = "Converts a mentioned role from a pingable role to a normal one."
description = "This will make it so that the role is no longer bound by a cooldown as to how many often it can be mentioned. It will also mean that there will no longer be a reaction menu for users to receive a role."
usage = "<one or many role mentions>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-convert-pingable-one-or-many-role-mentions"

[help.pingme_role_cooldown]
help_string = "Sets the ping cooldown for the given role."
description = "This will set the number of seconds users must wait before the role can be mentioned again."
usage = "<role mention | role ID> <cooldown in seconds>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-role-cooldown-role-mention--role-id-cooldown-in-seconds"

[help.pingme_role_emoji]
help_string = "Sets the emoji for the given role."
description = "If the mentioned role is a pingable role, this will set the emoji used in the role's reaction menu."
usage = "<role mention | role ID> <emoji>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-role-emoji-role-mention--role-id-emoji"

[help.pingme_disable_role]
help_string = "Disables a pingable role."
description = "If the role mentioned is a pingable role, this will stop it from being mentioned and will also disable the reaction menu for the role."
usage = "<one or many role mentions>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-disable-role-one-or-many-role-mentions"

[help.pingme_enable_role]
help_string = "Enables a pingable role."
description = "If the role mentioned is a pingable role, it will allow the role to be mentioned with it's mention cooldown in place and will enable the reaction menu."
usage = "<one or many role mentions>"
readme_url = "https://github.com/FragSoc/esports-bot#pingme-enable-role-one-or-many-role-mentions"

[logging]
channel_set = "Logging channel has been set to <#{channel_id!s}>"
channel_set_already = "Logging channel already set to this channel"
Expand Down