Add context menu for starboard
This commit is contained in:
parent
a317d3d616
commit
f9f2fa36fc
3 changed files with 24 additions and 17 deletions
|
@ -21,10 +21,11 @@ repos:
|
||||||
- id: black
|
- id: black
|
||||||
args: [--line-length=120]
|
args: [--line-length=120]
|
||||||
|
|
||||||
- repo: https://github.com/asottile/reorder_python_imports
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
rev: v2.6.0
|
rev: V5.9.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: reorder-python-imports
|
- id: isort
|
||||||
|
args: ["--profile", "black"]
|
||||||
|
|
||||||
- repo: https://github.com/pycqa/flake8
|
- repo: https://github.com/pycqa/flake8
|
||||||
rev: 3.9.2
|
rev: 3.9.2
|
||||||
|
|
|
@ -2,16 +2,18 @@
|
||||||
from discord import TextChannel
|
from discord import TextChannel
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.utils import find
|
from discord.utils import find
|
||||||
from discord_slash import cog_ext
|
from discord_slash import SlashContext, cog_ext
|
||||||
from discord_slash import SlashContext
|
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_commands import create_option
|
||||||
from discord_slash.utils.manage_components import create_actionrow
|
from discord_slash.utils.manage_components import (
|
||||||
from discord_slash.utils.manage_components import create_select
|
create_actionrow,
|
||||||
from discord_slash.utils.manage_components import create_select_option
|
create_select,
|
||||||
from discord_slash.utils.manage_components import wait_for_component
|
create_select_option,
|
||||||
|
wait_for_component,
|
||||||
|
)
|
||||||
|
|
||||||
from jarvis.db.models import Star
|
from jarvis.db.models import Star, Starboard
|
||||||
from jarvis.db.models import Starboard
|
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.permissions import admin_or_permissions
|
from jarvis.utils.permissions import admin_or_permissions
|
||||||
|
|
||||||
|
@ -110,6 +112,10 @@ class StarboardCog(commands.Cog):
|
||||||
else:
|
else:
|
||||||
await ctx.send(f"Starboard not found in {channel.mention}.", hidden=True)
|
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(
|
@cog_ext.cog_subcommand(
|
||||||
base="star",
|
base="star",
|
||||||
name="add",
|
name="add",
|
||||||
|
@ -169,10 +175,10 @@ class StarboardCog(commands.Cog):
|
||||||
|
|
||||||
starboard = channel_list[int(com_ctx.selected_options[0])]
|
starboard = channel_list[int(com_ctx.selected_options[0])]
|
||||||
|
|
||||||
|
if not isinstance(message, SlashMessage):
|
||||||
if message.startswith("https://"):
|
if message.startswith("https://"):
|
||||||
message = message.split("/")[-1]
|
message = message.split("/")[-1]
|
||||||
|
message = await channel.fetch_message(message.id)
|
||||||
message = await channel.fetch_message(int(message))
|
|
||||||
|
|
||||||
exists = Star.objects(
|
exists = Star.objects(
|
||||||
message=message.id,
|
message=message.id,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
ButtonPaginator>=0.0.3
|
|
||||||
discord-py>=1.7, <2
|
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
|
GitPython>=3.1, <4
|
||||||
mongoengine>=0.23, <1
|
mongoengine>=0.23, <1
|
||||||
opencv-python>=4.5, <5
|
opencv-python>=4.5, <5
|
||||||
|
|
Loading…
Add table
Reference in a new issue