Add context menu for starboard

This commit is contained in:
Zeva Rose 2021-09-01 20:23:16 -06:00
parent a317d3d616
commit f9f2fa36fc
3 changed files with 24 additions and 17 deletions

View file

@ -21,10 +21,11 @@ repos:
- id: black
args: [--line-length=120]
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
- repo: https://github.com/pre-commit/mirrors-isort
rev: V5.9.3
hooks:
- id: reorder-python-imports
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pycqa/flake8
rev: 3.9.2

View file

@ -2,16 +2,18 @@
from discord import TextChannel
from discord.ext import commands
from discord.utils import find
from discord_slash import cog_ext
from discord_slash import SlashContext
from discord_slash import SlashContext, cog_ext
from discord_slash.context import MenuContext
from discord_slash.model import ContextMenuType, SlashMessage
from discord_slash.utils.manage_commands import create_option
from discord_slash.utils.manage_components import create_actionrow
from discord_slash.utils.manage_components import create_select
from discord_slash.utils.manage_components import create_select_option
from discord_slash.utils.manage_components import wait_for_component
from discord_slash.utils.manage_components import (
create_actionrow,
create_select,
create_select_option,
wait_for_component,
)
from jarvis.db.models import Star
from jarvis.db.models import Starboard
from jarvis.db.models import Star, Starboard
from jarvis.utils import build_embed
from jarvis.utils.permissions import admin_or_permissions
@ -110,6 +112,10 @@ class StarboardCog(commands.Cog):
else:
await ctx.send(f"Starboard not found in {channel.mention}.", hidden=True)
@cog_ext.cog_context_menu(name="Star Message", target=ContextMenuType.MESSAGE)
async def _star_message(self, ctx: MenuContext) -> None:
await self._star_add.invoke(ctx, ctx.target_message)
@cog_ext.cog_subcommand(
base="star",
name="add",
@ -169,10 +175,10 @@ class StarboardCog(commands.Cog):
starboard = channel_list[int(com_ctx.selected_options[0])]
if not isinstance(message, SlashMessage):
if message.startswith("https://"):
message = message.split("/")[-1]
message = await channel.fetch_message(int(message))
message = await channel.fetch_message(message.id)
exists = Star.objects(
message=message.id,

View file

@ -1,6 +1,6 @@
ButtonPaginator>=0.0.3
discord-py>=1.7, <2
discord-py-slash-command>=2.3.2, <3
discord-py-slash-command>=3.0.1, <4
dpy-slash-button-paginator>=1.0.0, <2
GitPython>=3.1, <4
mongoengine>=0.23, <1
opencv-python>=4.5, <5