Rename starboard -> pinboard for UX

This commit is contained in:
Zeva Rose 2023-01-01 18:04:49 -07:00
parent 4e906ca051
commit 0a096e4831

View file

@ -36,8 +36,8 @@ supported_images = [
]
class StarboardCog(Extension):
"""JARVIS Starboard Cog."""
class PinboardCog(Extension):
"""JARVIS Pinboard Cog."""
def __init__(self, bot: Client):
self.bot = bot
@ -54,27 +54,27 @@ class StarboardCog(Extension):
self.logger.debug(f"Failed to delete star {star.id}'s message.")
await star.delete()
starboard = SlashCommand(name="starboard", description="Extra pins! Manage starboards")
pinboard = SlashCommand(name="pinboard", description="Extra pins! Manage pinboards")
@starboard.subcommand(
@pinboard.subcommand(
sub_cmd_name="list",
sub_cmd_description="List all starboards",
sub_cmd_description="List all pinboards",
)
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _list(self, ctx: InteractionContext) -> None:
starboards = await Starboard.find(q(guild=ctx.guild.id)).to_list(None)
if starboards != []:
message = "Available Starboards:\n"
message = "Available Pinboards:\n"
for s in starboards:
message += f"<#{s.channel}>\n"
await ctx.send(message)
else:
await ctx.send("No Starboards available.")
await ctx.send("No Pinboards available.")
@starboard.subcommand(sub_cmd_name="create", sub_cmd_description="Create a starboard")
@pinboard.subcommand(sub_cmd_name="create", sub_cmd_description="Create a Pinboard")
@slash_option(
name="channel",
description="Starboard channel",
description="Pinboard channel",
opt_type=OptionTypes.CHANNEL,
required=True,
)
@ -92,12 +92,12 @@ class StarboardCog(Extension):
exists = await Starboard.find_one(q(channel=channel.id, guild=ctx.guild.id))
if exists:
await ctx.send(f"Starboard already exists at {channel.mention}.", ephemeral=True)
await ctx.send(f"Pinboard already exists at {channel.mention}.", ephemeral=True)
return
count = await Starboard.count_documents(q(guild=ctx.guild.id))
if count >= 25:
await ctx.send("25 starboard limit reached", ephemeral=True)
await ctx.send("25 pinboard limit reached", ephemeral=True)
return
await Starboard(
@ -105,12 +105,12 @@ class StarboardCog(Extension):
channel=channel.id,
admin=ctx.author.id,
).commit()
await ctx.send(f"Starboard created. Check it out at {channel.mention}.")
await ctx.send(f"Pinboard created. Check it out at {channel.mention}.")
@starboard.subcommand(sub_cmd_name="delete", sub_cmd_description="Delete a starboard")
@pinboard.subcommand(sub_cmd_name="delete", sub_cmd_description="Delete a pinboard")
@slash_option(
name="channel",
description="Starboard channel",
description="Pinboard channel",
opt_type=OptionTypes.CHANNEL,
required=True,
)
@ -120,9 +120,9 @@ class StarboardCog(Extension):
if found:
await found.delete()
asyncio.create_task(self._purge_starboard(ctx, found))
await ctx.send(f"Starboard deleted from {channel.mention}.")
await ctx.send(f"Pinboard deleted from {channel.mention}.")
else:
await ctx.send(f"Starboard not found in {channel.mention}.", ephemeral=True)
await ctx.send(f"Pinboard not found in {channel.mention}.", ephemeral=True)
async def _star_add(
self,
@ -134,7 +134,7 @@ class StarboardCog(Extension):
channel = ctx.channel
starboards = await Starboard.find(q(guild=ctx.guild.id)).to_list(None)
if not starboards:
await ctx.send("No starboards exist.", ephemeral=True)
await ctx.send("No pinboards exist.", ephemeral=True)
return
await ctx.defer()
@ -155,7 +155,7 @@ class StarboardCog(Extension):
if c and isinstance(c, GuildText):
channel_list.append(c)
else:
self.logger.warning(f"Starboard {starboard.channel} no longer valid in {ctx.guild.name}")
self.logger.warning(f"Pinboard {starboard.channel} no longer valid in {ctx.guild.name}")
to_delete.append(starboard)
for starboard in to_delete:
@ -179,7 +179,7 @@ class StarboardCog(Extension):
components = [ActionRow(select)]
msg = await ctx.send(content="Choose a starboard", components=components)
msg = await ctx.send(content="Choose a pinboard", components=components)
com_ctx = await self.bot.wait_for_component(
messages=msg,
@ -200,7 +200,7 @@ class StarboardCog(Extension):
if exists:
await ctx.send(
f"Message already sent to Starboard {starboard.mention}",
f"Message already sent to Pinboard {starboard.mention}",
ephemeral=True,
)
return
@ -250,16 +250,16 @@ class StarboardCog(Extension):
components[0].components[0].disabled = True
await com_ctx.context.edit_origin(
content=f"Message saved to Starboard.\nSee it in {starboard.mention}",
content=f"Message saved to Pinboard.\nSee it in {starboard.mention}",
components=components,
)
@context_menu(name="Star Message", context_type=CommandTypes.MESSAGE)
@context_menu(name="Pin Message", context_type=CommandTypes.MESSAGE)
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _star_message(self, ctx: InteractionContext) -> None:
await self._star_add(ctx, message=str(ctx.target_id))
def setup(bot: Client) -> None:
"""Add StarboardCog to JARVIS"""
StarboardCog(bot)
"""Add PinboardCog to JARVIS"""
PinboardCog(bot)