Anaffer migration (dis-snek -> naff rename)
This commit is contained in:
parent
602cea9058
commit
8e07dceed7
33 changed files with 296 additions and 294 deletions
|
@ -3,9 +3,9 @@ import logging
|
|||
|
||||
import jurigged
|
||||
import rook
|
||||
from dis_snek import Intents
|
||||
from jarvis_core.db import connect
|
||||
from jarvis_core.log import get_logger
|
||||
from naff import Intents
|
||||
|
||||
from jarvis import const
|
||||
from jarvis.client import Jarvis
|
||||
|
|
|
@ -5,27 +5,27 @@ import traceback
|
|||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from aiohttp import ClientSession
|
||||
from dis_snek import Snake, listen
|
||||
from dis_snek.api.events.discord import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Autopurge, Autoreact, Roleping, Setting, Warning
|
||||
from jarvis_core.filters import invites, url
|
||||
from jarvis_core.util.ansi import RESET, Fore, Format, fmt
|
||||
from naff import Client, listen
|
||||
from naff.api.events.discord import (
|
||||
MemberAdd,
|
||||
MemberRemove,
|
||||
MessageCreate,
|
||||
MessageDelete,
|
||||
MessageUpdate,
|
||||
)
|
||||
from dis_snek.client.errors import CommandCheckFailure, CommandOnCooldown, HTTPException
|
||||
from dis_snek.client.utils.misc_utils import find_all
|
||||
from dis_snek.models.discord.channel import DMChannel
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.enums import Permissions
|
||||
from dis_snek.models.discord.message import Message
|
||||
from dis_snek.models.snek.context import Context, InteractionContext, PrefixedContext
|
||||
from dis_snek.models.snek.tasks.task import Task
|
||||
from dis_snek.models.snek.tasks.triggers import IntervalTrigger
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Autopurge, Autoreact, Roleping, Setting, Warning
|
||||
from jarvis_core.filters import invites, url
|
||||
from jarvis_core.util.ansi import RESET, Fore, Format, fmt
|
||||
from naff.client.errors import CommandCheckFailure, CommandOnCooldown, HTTPException
|
||||
from naff.client.utils.misc_utils import find_all
|
||||
from naff.models.discord.channel import DMChannel
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.enums import Permissions
|
||||
from naff.models.discord.message import Message
|
||||
from naff.models.naff.context import Context, InteractionContext, PrefixedContext
|
||||
from naff.models.naff.tasks.task import Task
|
||||
from naff.models.naff.tasks.triggers import IntervalTrigger
|
||||
from pastypy import AsyncPaste as Paste
|
||||
|
||||
from jarvis import const
|
||||
|
@ -55,7 +55,7 @@ VAL_FMT = fmt(Fore.WHITE)
|
|||
CMD_FMT = fmt(Fore.GREEN, Format.BOLD)
|
||||
|
||||
|
||||
class Jarvis(Snake):
|
||||
class Jarvis(Client):
|
||||
def __init__(self, *args, **kwargs): # noqa: ANN002 ANN003
|
||||
super().__init__(*args, **kwargs)
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""JARVIS Admin Cogs."""
|
||||
import logging
|
||||
|
||||
from dis_snek import Snake
|
||||
from naff import Client
|
||||
|
||||
from jarvis.cogs.admin import ban, kick, lock, lockdown, mute, purge, roleping, warning
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add admin cogs to JARVIS"""
|
||||
logger = logging.getLogger(__name__)
|
||||
msg = "Loaded jarvis.cogs.admin.{}"
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
"""JARVIS BanCog."""
|
||||
import re
|
||||
|
||||
from dis_snek import InteractionContext, Permissions
|
||||
from dis_snek.client.utils.misc_utils import find, find_all
|
||||
from dis_snek.ext.paginators import Paginator
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.user import User
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Ban, Unban
|
||||
from naff import InteractionContext, Permissions
|
||||
from naff.client.utils.misc_utils import find, find_all
|
||||
from naff.ext.paginators import Paginator
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.user import User
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
SlashCommandChoice,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Ban, Unban
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cogs import ModcaseCog
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
"""JARVIS KickCog."""
|
||||
from dis_snek import InteractionContext, Permissions
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.user import User
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db.models import Kick
|
||||
from naff import InteractionContext, Permissions
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.user import User
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db.models import Kick
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cogs import ModcaseCog
|
||||
|
|
|
@ -2,26 +2,26 @@
|
|||
import logging
|
||||
from typing import Union
|
||||
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import get
|
||||
from dis_snek.models.discord.channel import GuildText, GuildVoice
|
||||
from dis_snek.models.discord.enums import Permissions
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Lock, Permission
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.client.utils.misc_utils import get
|
||||
from naff.models.discord.channel import GuildText, GuildVoice
|
||||
from naff.models.discord.enums import Permissions
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Lock, Permission
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class LockCog(Scale):
|
||||
class LockCog(Cog):
|
||||
"""JARVIS LockCog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
"""JARVIS LockdownCog."""
|
||||
import logging
|
||||
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import find_all, get
|
||||
from dis_snek.models.discord.channel import GuildCategory, GuildChannel
|
||||
from dis_snek.models.discord.enums import Permissions
|
||||
from dis_snek.models.discord.guild import Guild
|
||||
from dis_snek.models.discord.user import Member
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Lock, Lockdown, Permission
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.client.utils.misc_utils import find_all, get
|
||||
from naff.models.discord.channel import GuildCategory, GuildChannel
|
||||
from naff.models.discord.enums import Permissions
|
||||
from naff.models.discord.guild import Guild
|
||||
from naff.models.discord.user import Member
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Lock, Lockdown, Permission
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
async def lock(bot: Snake, target: GuildChannel, admin: Member, reason: str, duration: int) -> None:
|
||||
async def lock(
|
||||
bot: Client, target: GuildChannel, admin: Member, reason: str, duration: int
|
||||
) -> None:
|
||||
"""
|
||||
Lock an existing channel
|
||||
|
||||
|
@ -44,7 +46,7 @@ async def lock(bot: Snake, target: GuildChannel, admin: Member, reason: str, dur
|
|||
).commit()
|
||||
|
||||
|
||||
async def lock_all(bot: Snake, guild: Guild, admin: Member, reason: str, duration: int) -> None:
|
||||
async def lock_all(bot: Client, guild: Guild, admin: Member, reason: str, duration: int) -> None:
|
||||
"""
|
||||
Lock all channels
|
||||
|
||||
|
@ -64,7 +66,7 @@ async def lock_all(bot: Snake, guild: Guild, admin: Member, reason: str, duratio
|
|||
await lock(bot, channel, admin, reason, duration)
|
||||
|
||||
|
||||
async def unlock_all(bot: Snake, guild: Guild, admin: Member) -> None:
|
||||
async def unlock_all(bot: Client, guild: Guild, admin: Member) -> None:
|
||||
"""
|
||||
Unlock all locked channels
|
||||
|
||||
|
@ -92,10 +94,10 @@ async def unlock_all(bot: Snake, guild: Guild, admin: Member) -> None:
|
|||
await lockdown.commit()
|
||||
|
||||
|
||||
class LockdownCog(Scale):
|
||||
class LockdownCog(Cog):
|
||||
"""JARVIS LockdownCog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@ from datetime import datetime, timedelta, timezone
|
|||
|
||||
from dateparser import parse
|
||||
from dateparser_data.settings import default_parsers
|
||||
from dis_snek import InteractionContext, Permissions
|
||||
from dis_snek.client.errors import Forbidden
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
|
||||
from dis_snek.models.discord.user import Member
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db.models import Mute
|
||||
from naff import InteractionContext, Permissions
|
||||
from naff.client.errors import Forbidden
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.modal import InputText, Modal, TextStyles
|
||||
from naff.models.discord.user import Member
|
||||
from naff.models.naff.application_commands import (
|
||||
CommandTypes,
|
||||
OptionTypes,
|
||||
SlashCommandChoice,
|
||||
|
@ -17,8 +18,7 @@ from dis_snek.models.snek.application_commands import (
|
|||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db.models import Mute
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cogs import ModcaseCog
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
"""JARVIS PurgeCog."""
|
||||
import logging
|
||||
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.models.discord.channel import GuildText
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Autopurge, Purge
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.models.discord.channel import GuildText
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Autopurge, Purge
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class PurgeCog(Scale):
|
||||
class PurgeCog(Cog):
|
||||
"""JARVIS PurgeCog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
"""JARVIS RolepingCog."""
|
||||
import logging
|
||||
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import find_all
|
||||
from dis_snek.ext.paginators import Paginator
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.role import Role
|
||||
from dis_snek.models.discord.user import Member
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Roleping
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.client.utils.misc_utils import find_all
|
||||
from naff.ext.paginators import Paginator
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.role import Role
|
||||
from naff.models.discord.user import Member
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Roleping
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class RolepingCog(Scale):
|
||||
class RolepingCog(Cog):
|
||||
"""JARVIS RolepingCog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
"""JARVIS WarningCog."""
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from dis_snek import InteractionContext, Permissions
|
||||
from dis_snek.client.utils.misc_utils import get_all
|
||||
from dis_snek.ext.paginators import Paginator
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.user import Member
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Warning
|
||||
from naff import InteractionContext, Permissions
|
||||
from naff.client.utils.misc_utils import get_all
|
||||
from naff.ext.paginators import Paginator
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.user import Member
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Warning
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cogs import ModcaseCog
|
||||
|
|
|
@ -3,26 +3,26 @@ import logging
|
|||
import re
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import find
|
||||
from dis_snek.models.discord.channel import GuildText
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Autoreact
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.client.utils.misc_utils import find
|
||||
from naff.models.discord.channel import GuildText
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Autoreact
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.data.unicode import emoji_list
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class AutoReactCog(Scale):
|
||||
class AutoReactCog(Cog):
|
||||
"""JARVIS Autoreact Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.custom_emote = re.compile(r"^<:\w+:(\d+)>$")
|
||||
|
@ -206,6 +206,6 @@ class AutoReactCog(Scale):
|
|||
await ctx.send(message)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add AutoReactCog to JARVIS"""
|
||||
AutoReactCog(bot)
|
||||
|
|
|
@ -5,22 +5,22 @@ from io import BytesIO
|
|||
|
||||
import psutil
|
||||
from aiofile import AIOFile, LineReader
|
||||
from dis_snek import PrefixedContext, Scale, Snake, prefixed_command
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.file import File
|
||||
from naff import Client, Cog, PrefixedContext, prefixed_command
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.file import File
|
||||
from rich.console import Console
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.updates import update
|
||||
|
||||
|
||||
class BotutilCog(Scale):
|
||||
class BotutilCog(Cog):
|
||||
"""JARVIS Bot Utility Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.add_scale_check(self.is_owner)
|
||||
self.add_cog_check(self.is_owner)
|
||||
|
||||
async def is_owner(self, ctx: PrefixedContext) -> bool:
|
||||
"""Checks if author is bot owner."""
|
||||
|
@ -115,6 +115,6 @@ class BotutilCog(Scale):
|
|||
await ctx.reply(embed=embed)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add BotutilCog to JARVIS"""
|
||||
BotutilCog(bot)
|
||||
|
|
|
@ -3,20 +3,20 @@ import logging
|
|||
import re
|
||||
|
||||
import aiohttp
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.ext.paginators import Paginator
|
||||
from dis_snek.models.discord.components import ActionRow, Button, ButtonStyles
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.user import Member, User
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Guess
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.ext.paginators import Paginator
|
||||
from naff.models.discord.components import ActionRow, Button, ButtonStyles
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.user import Member, User
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Guess
|
||||
from naff.models.naff.command import cooldown
|
||||
from naff.models.naff.cooldowns import Buckets
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
|
@ -29,10 +29,10 @@ invites = re.compile(
|
|||
)
|
||||
|
||||
|
||||
class CTCCog(Scale):
|
||||
class CTCCog(Cog):
|
||||
"""JARVIS Complete the Code 2 Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self._session = aiohttp.ClientSession()
|
||||
|
@ -146,6 +146,6 @@ class CTCCog(Scale):
|
|||
await paginator.send(ctx)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add CTCCog to JARVIS"""
|
||||
CTCCog(bot)
|
||||
|
|
|
@ -3,15 +3,15 @@ import logging
|
|||
import re
|
||||
|
||||
import aiohttp
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from naff.models.naff.command import cooldown
|
||||
from naff.models.naff.cooldowns import Buckets
|
||||
|
||||
from jarvis.config import get_config
|
||||
from jarvis.data.dbrand import shipping_lookup
|
||||
|
@ -20,14 +20,14 @@ from jarvis.utils import build_embed
|
|||
guild_ids = [862402786116763668] # [578757004059738142, 520021794380447745, 862402786116763668]
|
||||
|
||||
|
||||
class DbrandCog(Scale):
|
||||
class DbrandCog(Cog):
|
||||
"""
|
||||
dbrand functions for JARVIS
|
||||
|
||||
Mostly support functions. Credit @cpixl for the shipping API
|
||||
"""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.base_url = "https://dbrand.com/"
|
||||
|
@ -197,6 +197,6 @@ class DbrandCog(Scale):
|
|||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add dbrandcog to JARVIS"""
|
||||
DbrandCog(bot)
|
||||
|
|
|
@ -8,20 +8,20 @@ import uuid as uuidpy
|
|||
|
||||
import ulid as ulidpy
|
||||
from bson import ObjectId
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.message import Attachment
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.filters import invites, url
|
||||
from jarvis_core.util import convert_bytesize, hash
|
||||
from jarvis_core.util.http import get_size
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.message import Attachment
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommandChoice,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from jarvis_core.filters import invites, url
|
||||
from jarvis_core.util import convert_bytesize, hash
|
||||
from jarvis_core.util.http import get_size
|
||||
from naff.models.naff.command import cooldown
|
||||
from naff.models.naff.cooldowns import Buckets
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
|
@ -45,10 +45,10 @@ UUID_GET = {3: uuidpy.uuid3, 5: uuidpy.uuid5}
|
|||
MAX_FILESIZE = 5 * (1024**3) # 5GB
|
||||
|
||||
|
||||
class DevCog(Scale):
|
||||
class DevCog(Cog):
|
||||
"""JARVIS Developer Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -275,6 +275,6 @@ class DevCog(Scale):
|
|||
await ctx.send(f"```haskell\n{output}\n```")
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add DevCog to JARVIS"""
|
||||
DevCog(bot)
|
||||
|
|
|
@ -4,20 +4,20 @@ import logging
|
|||
from datetime import datetime
|
||||
|
||||
import gitlab
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.ext.paginators import Paginator
|
||||
from dis_snek.models.discord.embed import Embed, EmbedField
|
||||
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
|
||||
from dis_snek.models.discord.user import Member
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.ext.paginators import Paginator
|
||||
from naff.models.discord.embed import Embed, EmbedField
|
||||
from naff.models.discord.modal import InputText, Modal, TextStyles
|
||||
from naff.models.discord.user import Member
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
SlashCommandChoice,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from naff.models.naff.command import cooldown
|
||||
from naff.models.naff.cooldowns import Buckets
|
||||
|
||||
from jarvis.config import JarvisConfig
|
||||
from jarvis.utils import build_embed
|
||||
|
@ -25,10 +25,10 @@ from jarvis.utils import build_embed
|
|||
guild_ids = [862402786116763668]
|
||||
|
||||
|
||||
class GitlabCog(Scale):
|
||||
class GitlabCog(Cog):
|
||||
"""JARVIS GitLab Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
config = JarvisConfig.from_yaml()
|
||||
|
@ -465,7 +465,7 @@ class GitlabCog(Scale):
|
|||
await resp.send(embed=embed)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add GitlabCog to JARVIS if Gitlab token exists."""
|
||||
if JarvisConfig.from_yaml().gitlab_token:
|
||||
GitlabCog(bot)
|
||||
|
|
|
@ -6,30 +6,30 @@ from io import BytesIO
|
|||
import aiohttp
|
||||
import cv2
|
||||
import numpy as np
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.file import File
|
||||
from dis_snek.models.discord.message import Attachment
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.util import convert_bytesize, unconvert_bytesize
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.file import File
|
||||
from naff.models.discord.message import Attachment
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from jarvis_core.util import convert_bytesize, unconvert_bytesize
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
MIN_ACCURACY = 0.80
|
||||
|
||||
|
||||
class ImageCog(Scale):
|
||||
class ImageCog(Cog):
|
||||
"""
|
||||
Image processing functions for JARVIS
|
||||
|
||||
May be categorized under util later
|
||||
"""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self._session = aiohttp.ClientSession()
|
||||
|
@ -153,6 +153,6 @@ class ImageCog(Scale):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add ImageCog to JARVIS"""
|
||||
ImageCog(bot)
|
||||
|
|
|
@ -7,20 +7,20 @@ from asyncpraw import Reddit
|
|||
from asyncpraw.models.reddit.submission import Submission
|
||||
from asyncpraw.models.reddit.submission import Subreddit as Sub
|
||||
from asyncprawcore.exceptions import Forbidden, NotFound, Redirect
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import get
|
||||
from dis_snek.models.discord.channel import ChannelTypes, GuildText
|
||||
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
|
||||
from dis_snek.models.discord.embed import Embed
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Subreddit, SubredditFollow
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.client.utils.misc_utils import get
|
||||
from naff.models.discord.channel import ChannelTypes, GuildText
|
||||
from naff.models.discord.components import ActionRow, Select, SelectOption
|
||||
from naff.models.discord.embed import Embed
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
SlashCommandChoice,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Subreddit, SubredditFollow
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis import const
|
||||
from jarvis.config import JarvisConfig
|
||||
|
@ -30,10 +30,10 @@ from jarvis.utils.permissions import admin_or_permissions
|
|||
DEFAULT_USER_AGENT = f"python:JARVIS:{const.__version__} (by u/zevaryx)"
|
||||
|
||||
|
||||
class RedditCog(Scale):
|
||||
class RedditCog(Cog):
|
||||
"""JARVIS Reddit Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
config = JarvisConfig.from_yaml()
|
||||
|
@ -385,7 +385,7 @@ class RedditCog(Scale):
|
|||
await ctx.send(embeds=embeds)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add RedditCog to JARVIS"""
|
||||
if JarvisConfig.from_yaml().reddit:
|
||||
RedditCog(bot)
|
||||
|
|
|
@ -8,20 +8,20 @@ from typing import List
|
|||
from bson import ObjectId
|
||||
from dateparser import parse
|
||||
from dateparser_data.settings import default_parsers
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import get
|
||||
from dis_snek.models.discord.channel import GuildChannel
|
||||
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
|
||||
from dis_snek.models.discord.embed import Embed, EmbedField
|
||||
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Reminder
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.client.utils.misc_utils import get
|
||||
from naff.models.discord.channel import GuildChannel
|
||||
from naff.models.discord.components import ActionRow, Select, SelectOption
|
||||
from naff.models.discord.embed import Embed, EmbedField
|
||||
from naff.models.discord.modal import InputText, Modal, TextStyles
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Reminder
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
|
@ -33,10 +33,10 @@ invites = re.compile(
|
|||
)
|
||||
|
||||
|
||||
class RemindmeCog(Scale):
|
||||
class RemindmeCog(Cog):
|
||||
"""JARVIS Remind Me Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -336,6 +336,6 @@ class RemindmeCog(Scale):
|
|||
self.logger.debug("Ignoring deletion error")
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add RemindmeCog to JARVIS"""
|
||||
RemindmeCog(bot)
|
||||
|
|
|
@ -2,29 +2,29 @@
|
|||
import asyncio
|
||||
import logging
|
||||
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import get
|
||||
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.role import Role
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Rolegiver
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.client.utils.misc_utils import get
|
||||
from naff.models.discord.components import ActionRow, Select, SelectOption
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.role import Role
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check, cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Rolegiver
|
||||
from naff.models.naff.command import check, cooldown
|
||||
from naff.models.naff.cooldowns import Buckets
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class RolegiverCog(Scale):
|
||||
class RolegiverCog(Cog):
|
||||
"""JARVIS Role Giver Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -385,6 +385,6 @@ class RolegiverCog(Scale):
|
|||
await ctx.send("Rolegiver cleanup finished")
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add RolegiverCog to JARVIS"""
|
||||
RolegiverCog(bot)
|
||||
|
|
|
@ -3,29 +3,29 @@ import asyncio
|
|||
import logging
|
||||
from typing import Any
|
||||
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.models.discord.channel import GuildText
|
||||
from dis_snek.models.discord.components import ActionRow, Button, ButtonStyles
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.enums import Permissions
|
||||
from dis_snek.models.discord.role import Role
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Setting
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.models.discord.channel import GuildText
|
||||
from naff.models.discord.components import ActionRow, Button, ButtonStyles
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.enums import Permissions
|
||||
from naff.models.discord.role import Role
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Setting
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class SettingsCog(Scale):
|
||||
class SettingsCog(Cog):
|
||||
"""JARVIS Settings Management Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -278,6 +278,6 @@ class SettingsCog(Scale):
|
|||
await message.edit(content="Guild settings not cleared", components=components)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add SettingsCog to JARVIS"""
|
||||
SettingsCog(bot)
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"""JARVIS Starboard Cog."""
|
||||
import logging
|
||||
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.models.discord.channel import GuildText
|
||||
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
|
||||
from dis_snek.models.discord.message import Message
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Star, Starboard
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.models.discord.channel import GuildText
|
||||
from naff.models.discord.components import ActionRow, Select, SelectOption
|
||||
from naff.models.discord.message import Message
|
||||
from naff.models.naff.application_commands import (
|
||||
CommandTypes,
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
context_menu,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Star, Starboard
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
@ -28,10 +28,10 @@ supported_images = [
|
|||
]
|
||||
|
||||
|
||||
class StarboardCog(Scale):
|
||||
class StarboardCog(Cog):
|
||||
"""JARVIS Starboard Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -318,6 +318,6 @@ class StarboardCog(Scale):
|
|||
await ctx.send(f"Star {id} deleted from {starboard.mention}")
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add StarboardCog to JARVIS"""
|
||||
StarboardCog(bot)
|
||||
|
|
|
@ -4,26 +4,26 @@ from datetime import datetime, timezone
|
|||
|
||||
from dateparser import parse
|
||||
from dateparser_data.settings import default_parsers
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.role import Role
|
||||
from dis_snek.models.discord.user import Member
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db.models import Temprole
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.role import Role
|
||||
from naff.models.discord.user import Member
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db.models import Temprole
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class TemproleCog(Scale):
|
||||
class TemproleCog(Cog):
|
||||
"""JARVIS Temporary Role Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -121,6 +121,6 @@ class TemproleCog(Scale):
|
|||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add TemproleCog to JARVIS"""
|
||||
TemproleCog(bot)
|
||||
|
|
|
@ -3,27 +3,27 @@ import asyncio
|
|||
import logging
|
||||
|
||||
import tweepy
|
||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
||||
from dis_snek.client.utils.misc_utils import get
|
||||
from dis_snek.models.discord.channel import GuildText
|
||||
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import TwitterAccount, TwitterFollow
|
||||
from naff import Client, Cog, InteractionContext, Permissions
|
||||
from naff.client.utils.misc_utils import get
|
||||
from naff.models.discord.channel import GuildText
|
||||
from naff.models.discord.components import ActionRow, Select, SelectOption
|
||||
from naff.models.naff.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommand,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import check
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import TwitterAccount, TwitterFollow
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.config import JarvisConfig
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class TwitterCog(Scale):
|
||||
class TwitterCog(Cog):
|
||||
"""JARVIS Twitter Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
config = JarvisConfig.from_yaml()
|
||||
|
@ -243,7 +243,7 @@ class TwitterCog(Scale):
|
|||
await message.edit(components=components)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add TwitterCog to JARVIS"""
|
||||
if JarvisConfig.from_yaml().twitter:
|
||||
TwitterCog(bot)
|
||||
|
|
|
@ -8,14 +8,14 @@ from io import BytesIO
|
|||
|
||||
import numpy as np
|
||||
from dateparser import parse
|
||||
from dis_snek import InteractionContext, Scale, Snake, const
|
||||
from dis_snek.models.discord.channel import GuildCategory, GuildText, GuildVoice
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from dis_snek.models.discord.file import File
|
||||
from dis_snek.models.discord.guild import Guild
|
||||
from dis_snek.models.discord.role import Role
|
||||
from dis_snek.models.discord.user import Member, User
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
from naff import Client, Cog, InteractionContext, const
|
||||
from naff.models.discord.channel import GuildCategory, GuildText, GuildVoice
|
||||
from naff.models.discord.embed import EmbedField
|
||||
from naff.models.discord.file import File
|
||||
from naff.models.discord.guild import Guild
|
||||
from naff.models.discord.role import Role
|
||||
from naff.models.discord.user import Member, User
|
||||
from naff.models.naff.application_commands import (
|
||||
CommandTypes,
|
||||
OptionTypes,
|
||||
SlashCommandChoice,
|
||||
|
@ -23,8 +23,8 @@ from dis_snek.models.snek.application_commands import (
|
|||
slash_command,
|
||||
slash_option,
|
||||
)
|
||||
from dis_snek.models.snek.command import cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from naff.models.naff.command import cooldown
|
||||
from naff.models.naff.cooldowns import Buckets
|
||||
from PIL import Image
|
||||
from tzlocal import get_localzone
|
||||
|
||||
|
@ -36,14 +36,14 @@ from jarvis.utils import build_embed, get_repo_hash
|
|||
JARVIS_LOGO = Image.open("jarvis_small.png").convert("RGBA")
|
||||
|
||||
|
||||
class UtilCog(Scale):
|
||||
class UtilCog(Cog):
|
||||
"""
|
||||
Utility functions for JARVIS
|
||||
|
||||
Mostly system utility functions, but may change over time
|
||||
"""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -57,7 +57,7 @@ class UtilCog(Scale):
|
|||
uptime = int(self.bot.start_time.timestamp())
|
||||
|
||||
fields.append(EmbedField(name="Version", value=jconst.__version__, inline=True))
|
||||
fields.append(EmbedField(name="dis-snek", value=const.__version__, inline=True))
|
||||
fields.append(EmbedField(name="naff", value=const.__version__, inline=True))
|
||||
fields.append(EmbedField(name="Git Hash", value=get_repo_hash()[:7], inline=True))
|
||||
fields.append(EmbedField(name="Online Since", value=f"<t:{uptime}:F>", inline=False))
|
||||
num_domains = len(self.bot.phishing_domains)
|
||||
|
@ -375,6 +375,6 @@ class UtilCog(Scale):
|
|||
await ctx.send(embed=embed, ephemeral=private)
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add UtilCog to JARVIS"""
|
||||
UtilCog(bot)
|
||||
|
|
|
@ -3,13 +3,13 @@ import asyncio
|
|||
import logging
|
||||
from random import randint
|
||||
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.models.discord.components import Button, ButtonStyles, spread_to_rows
|
||||
from dis_snek.models.snek.application_commands import slash_command
|
||||
from dis_snek.models.snek.command import cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import Setting
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.models.discord.components import Button, ButtonStyles, spread_to_rows
|
||||
from naff.models.naff.application_commands import slash_command
|
||||
from naff.models.naff.command import cooldown
|
||||
from naff.models.naff.cooldowns import Buckets
|
||||
|
||||
|
||||
def create_layout() -> list:
|
||||
|
@ -30,10 +30,10 @@ def create_layout() -> list:
|
|||
return spread_to_rows(*buttons, max_in_row=3)
|
||||
|
||||
|
||||
class VerifyCog(Scale):
|
||||
class VerifyCog(Cog):
|
||||
"""JARVIS Verify Cog."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -108,6 +108,6 @@ class VerifyCog(Scale):
|
|||
self.logger.debug(f"User {ctx.author.id} failed to verify before timeout")
|
||||
|
||||
|
||||
def setup(bot: Snake) -> None:
|
||||
def setup(bot: Client) -> None:
|
||||
"""Add VerifyCog to JARVIS"""
|
||||
VerifyCog(bot)
|
||||
|
|
|
@ -16,7 +16,7 @@ class JarvisConfig(CConfig):
|
|||
OPTIONAL = {
|
||||
"sync": False,
|
||||
"log_level": "WARNING",
|
||||
"scales": None,
|
||||
"cogs": None,
|
||||
"events": True,
|
||||
"gitlab_token": None,
|
||||
"max_messages": 1000,
|
||||
|
|
|
@ -3,9 +3,9 @@ from datetime import datetime, timezone
|
|||
from pkgutil import iter_modules
|
||||
|
||||
import git
|
||||
from dis_snek.models.discord.embed import Embed, EmbedField
|
||||
from dis_snek.models.discord.guild import AuditLogEntry
|
||||
from dis_snek.models.discord.user import Member
|
||||
from naff.models.discord.embed import Embed, EmbedField
|
||||
from naff.models.discord.guild import AuditLogEntry
|
||||
from naff.models.discord.user import Member
|
||||
|
||||
from jarvis.config import get_config
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Cog wrapper for command caching."""
|
||||
import logging
|
||||
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.models.discord.embed import EmbedField
|
||||
from jarvis_core.db import q
|
||||
from jarvis_core.db.models import (
|
||||
Action,
|
||||
|
@ -14,6 +12,8 @@ from jarvis_core.db.models import (
|
|||
Setting,
|
||||
Warning,
|
||||
)
|
||||
from naff import Client, Cog, InteractionContext
|
||||
from naff.models.discord.embed import EmbedField
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
|
@ -21,13 +21,13 @@ MODLOG_LOOKUP = {"Ban": Ban, "Kick": Kick, "Mute": Mute, "Warning": Warning}
|
|||
IGNORE_COMMANDS = {"Ban": ["bans"], "Kick": [], "Mute": ["unmute"], "Warning": ["warnings"]}
|
||||
|
||||
|
||||
class ModcaseCog(Scale):
|
||||
class ModcaseCog(Cog):
|
||||
"""Cog wrapper for moderation case logging."""
|
||||
|
||||
def __init__(self, bot: Snake):
|
||||
def __init__(self, bot: Client):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.add_scale_postrun(self.log)
|
||||
self.add_cog_postrun(self.log)
|
||||
|
||||
async def log(self, ctx: InteractionContext, *_args: list, **kwargs: dict) -> None:
|
||||
"""
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""JARVIS bot-specific embeds."""
|
||||
from dis_snek.models.discord.embed import Embed, EmbedField
|
||||
from dis_snek.models.discord.user import Member
|
||||
from naff.models.discord.embed import Embed, EmbedField
|
||||
from naff.models.discord.user import Member
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Permissions wrappers."""
|
||||
from dis_snek import InteractionContext, Permissions
|
||||
from naff import InteractionContext, Permissions
|
||||
|
||||
from jarvis.config import get_config
|
||||
|
||||
|
|
|
@ -9,15 +9,15 @@ from types import FunctionType, ModuleType
|
|||
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional
|
||||
|
||||
import git
|
||||
from dis_snek.client.utils.misc_utils import find, find_all
|
||||
from dis_snek.models.snek.application_commands import SlashCommand
|
||||
from dis_snek.models.snek.scale import Scale
|
||||
from naff.client.utils.misc_utils import find, find_all
|
||||
from naff.models.naff.application_commands import SlashCommand
|
||||
from naff.models.naff.cog import Cog
|
||||
from rich.table import Table
|
||||
|
||||
import jarvis.cogs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dis_snek.client.client import Snake
|
||||
from naff.client.client import Client
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -40,7 +40,7 @@ def get_all_commands(module: ModuleType = jarvis.cogs) -> Dict[str, Callable]:
|
|||
commands = {}
|
||||
|
||||
def validate_ires(entry: Any) -> bool:
|
||||
return isclass(entry) and issubclass(entry, Scale) and entry is not Scale
|
||||
return isclass(entry) and issubclass(entry, Cog) and entry is not Cog
|
||||
|
||||
def validate_cog(cog: FunctionType) -> bool:
|
||||
return isinstance(cog, SlashCommand)
|
||||
|
@ -113,7 +113,7 @@ def get_git_changes(repo: git.Repo) -> dict:
|
|||
}
|
||||
|
||||
|
||||
async def update(bot: "Snake") -> Optional[UpdateResult]:
|
||||
async def update(bot: "Client") -> Optional[UpdateResult]:
|
||||
"""
|
||||
Update JARVIS and return an UpdateResult.
|
||||
|
||||
|
@ -150,17 +150,17 @@ async def update(bot: "Snake") -> Optional[UpdateResult]:
|
|||
for module in current_commands.keys():
|
||||
if module not in new_commands:
|
||||
logger.debug("Module %s removed after update", module)
|
||||
bot.shed_scale(module)
|
||||
bot.shed_Cog(module)
|
||||
unloaded.append(module)
|
||||
|
||||
logger.debug("Checking for new/modified commands")
|
||||
for module, commands in new_commands.items():
|
||||
logger.debug("Processing %s", module)
|
||||
if module not in current_commands:
|
||||
bot.grow_scale(module)
|
||||
bot.grow_Cog(module)
|
||||
loaded.append(module)
|
||||
elif len(current_commands[module]) != len(commands):
|
||||
bot.regrow_scale(module)
|
||||
bot.regrow_Cog(module)
|
||||
reloaded.append(module)
|
||||
else:
|
||||
for command in commands:
|
||||
|
@ -182,15 +182,15 @@ async def update(bot: "Snake") -> Optional[UpdateResult]:
|
|||
|
||||
# Check if number arguments have changed
|
||||
if len(old_args) != len(new_args):
|
||||
bot.regrow_scale(module)
|
||||
bot.regrow_Cog(module)
|
||||
reloaded.append(module)
|
||||
elif any(x not in old_arg_names for x in new_arg_names) or any(
|
||||
x not in new_arg_names for x in old_arg_names
|
||||
):
|
||||
bot.regrow_scale(module)
|
||||
bot.regrow_Cog(module)
|
||||
reloaded.append(module)
|
||||
elif any(new_args[idx].type != x.type for idx, x in enumerate(old_args)):
|
||||
bot.regrow_scale(module)
|
||||
bot.regrow_Cog(module)
|
||||
reloaded.append(module)
|
||||
|
||||
return UpdateResult(
|
||||
|
|
Loading…
Add table
Reference in a new issue