Rename starboard -> pinboard for UX
This commit is contained in:
parent
4e906ca051
commit
0a096e4831
1 changed files with 24 additions and 24 deletions
|
@ -36,8 +36,8 @@ supported_images = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class StarboardCog(Extension):
|
class PinboardCog(Extension):
|
||||||
"""JARVIS Starboard Cog."""
|
"""JARVIS Pinboard Cog."""
|
||||||
|
|
||||||
def __init__(self, bot: Client):
|
def __init__(self, bot: Client):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
@ -54,27 +54,27 @@ class StarboardCog(Extension):
|
||||||
self.logger.debug(f"Failed to delete star {star.id}'s message.")
|
self.logger.debug(f"Failed to delete star {star.id}'s message.")
|
||||||
await star.delete()
|
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_name="list",
|
||||||
sub_cmd_description="List all starboards",
|
sub_cmd_description="List all pinboards",
|
||||||
)
|
)
|
||||||
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
|
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
|
||||||
async def _list(self, ctx: InteractionContext) -> None:
|
async def _list(self, ctx: InteractionContext) -> None:
|
||||||
starboards = await Starboard.find(q(guild=ctx.guild.id)).to_list(None)
|
starboards = await Starboard.find(q(guild=ctx.guild.id)).to_list(None)
|
||||||
if starboards != []:
|
if starboards != []:
|
||||||
message = "Available Starboards:\n"
|
message = "Available Pinboards:\n"
|
||||||
for s in starboards:
|
for s in starboards:
|
||||||
message += f"<#{s.channel}>\n"
|
message += f"<#{s.channel}>\n"
|
||||||
await ctx.send(message)
|
await ctx.send(message)
|
||||||
else:
|
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(
|
@slash_option(
|
||||||
name="channel",
|
name="channel",
|
||||||
description="Starboard channel",
|
description="Pinboard channel",
|
||||||
opt_type=OptionTypes.CHANNEL,
|
opt_type=OptionTypes.CHANNEL,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
@ -92,12 +92,12 @@ class StarboardCog(Extension):
|
||||||
|
|
||||||
exists = await Starboard.find_one(q(channel=channel.id, guild=ctx.guild.id))
|
exists = await Starboard.find_one(q(channel=channel.id, guild=ctx.guild.id))
|
||||||
if exists:
|
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
|
return
|
||||||
|
|
||||||
count = await Starboard.count_documents(q(guild=ctx.guild.id))
|
count = await Starboard.count_documents(q(guild=ctx.guild.id))
|
||||||
if count >= 25:
|
if count >= 25:
|
||||||
await ctx.send("25 starboard limit reached", ephemeral=True)
|
await ctx.send("25 pinboard limit reached", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
await Starboard(
|
await Starboard(
|
||||||
|
@ -105,12 +105,12 @@ class StarboardCog(Extension):
|
||||||
channel=channel.id,
|
channel=channel.id,
|
||||||
admin=ctx.author.id,
|
admin=ctx.author.id,
|
||||||
).commit()
|
).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(
|
@slash_option(
|
||||||
name="channel",
|
name="channel",
|
||||||
description="Starboard channel",
|
description="Pinboard channel",
|
||||||
opt_type=OptionTypes.CHANNEL,
|
opt_type=OptionTypes.CHANNEL,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
@ -120,9 +120,9 @@ class StarboardCog(Extension):
|
||||||
if found:
|
if found:
|
||||||
await found.delete()
|
await found.delete()
|
||||||
asyncio.create_task(self._purge_starboard(ctx, found))
|
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:
|
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(
|
async def _star_add(
|
||||||
self,
|
self,
|
||||||
|
@ -134,7 +134,7 @@ class StarboardCog(Extension):
|
||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
starboards = await Starboard.find(q(guild=ctx.guild.id)).to_list(None)
|
starboards = await Starboard.find(q(guild=ctx.guild.id)).to_list(None)
|
||||||
if not starboards:
|
if not starboards:
|
||||||
await ctx.send("No starboards exist.", ephemeral=True)
|
await ctx.send("No pinboards exist.", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
|
@ -155,7 +155,7 @@ class StarboardCog(Extension):
|
||||||
if c and isinstance(c, GuildText):
|
if c and isinstance(c, GuildText):
|
||||||
channel_list.append(c)
|
channel_list.append(c)
|
||||||
else:
|
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)
|
to_delete.append(starboard)
|
||||||
|
|
||||||
for starboard in to_delete:
|
for starboard in to_delete:
|
||||||
|
@ -179,7 +179,7 @@ class StarboardCog(Extension):
|
||||||
|
|
||||||
components = [ActionRow(select)]
|
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(
|
com_ctx = await self.bot.wait_for_component(
|
||||||
messages=msg,
|
messages=msg,
|
||||||
|
@ -200,7 +200,7 @@ class StarboardCog(Extension):
|
||||||
|
|
||||||
if exists:
|
if exists:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"Message already sent to Starboard {starboard.mention}",
|
f"Message already sent to Pinboard {starboard.mention}",
|
||||||
ephemeral=True,
|
ephemeral=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
@ -250,16 +250,16 @@ class StarboardCog(Extension):
|
||||||
components[0].components[0].disabled = True
|
components[0].components[0].disabled = True
|
||||||
|
|
||||||
await com_ctx.context.edit_origin(
|
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,
|
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))
|
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
|
||||||
async def _star_message(self, ctx: InteractionContext) -> None:
|
async def _star_message(self, ctx: InteractionContext) -> None:
|
||||||
await self._star_add(ctx, message=str(ctx.target_id))
|
await self._star_add(ctx, message=str(ctx.target_id))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: Client) -> None:
|
def setup(bot: Client) -> None:
|
||||||
"""Add StarboardCog to JARVIS"""
|
"""Add PinboardCog to JARVIS"""
|
||||||
StarboardCog(bot)
|
PinboardCog(bot)
|
||||||
|
|
Loading…
Add table
Reference in a new issue