Fixed formatting with isort and black
All checks were successful
Test / build (push) Successful in 26s
All checks were successful
Test / build (push) Successful in 26s
This commit is contained in:
13
cli.py
13
cli.py
@@ -7,25 +7,32 @@ from javelina.modules.migrator import migrate_database
|
||||
|
||||
cli: Typer = Typer()
|
||||
|
||||
|
||||
@cli.command()
|
||||
def init(
|
||||
destination: Path = Option("config.json", help="File to write the default configuration to"),
|
||||
overwrite: bool = Option(False, help="Overwrite config if already exists")
|
||||
destination: Path = Option(
|
||||
"config.json", help="File to write the default configuration to"
|
||||
),
|
||||
overwrite: bool = Option(False, help="Overwrite config if already exists"),
|
||||
) -> None:
|
||||
example_path: Path = Path("config_example.json")
|
||||
|
||||
if destination.exists() and not overwrite:
|
||||
raise FileExistsError(f"File at {destination} already exists. Pass --overwrite to overwrite it")
|
||||
raise FileExistsError(
|
||||
f"File at {destination} already exists. Pass --overwrite to overwrite it"
|
||||
)
|
||||
|
||||
copyfile(example_path, destination)
|
||||
|
||||
echo(f"Copied default config to {destination}")
|
||||
|
||||
|
||||
@cli.command()
|
||||
def migrate() -> None:
|
||||
echo("Performing migrations...")
|
||||
migrate_database()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import logging
|
||||
from datetime import datetime, timedelta
|
||||
from logging import Logger
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Literal, Optional, List
|
||||
from typing import Any, Dict, List, Literal, Optional
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from aiohttp import ClientSession
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Dict
|
||||
|
||||
from bson import ObjectId
|
||||
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
from typing import Callable, List
|
||||
|
||||
from discord import ApplicationContext, Cog, slash_command, InteractionContextType, option, User, default_permissions, \
|
||||
Forbidden, Message
|
||||
from discord import (
|
||||
ApplicationContext,
|
||||
Cog,
|
||||
Forbidden,
|
||||
InteractionContextType,
|
||||
Message,
|
||||
User,
|
||||
default_permissions,
|
||||
option,
|
||||
slash_command,
|
||||
)
|
||||
from libbot.i18n import _, in_every_locale
|
||||
|
||||
from javelina.classes.pycord_bot import PycordBot
|
||||
@@ -64,29 +73,40 @@ class CogAdmin(Cog):
|
||||
@option("amount", description="How many messages to delete", min_value=1, max_value=100)
|
||||
@option("user", description="User whose balance to check (if not your own)", required=False)
|
||||
@default_permissions(manage_messages=True)
|
||||
async def command_clear(self, ctx: ApplicationContext, amount: int, user: User = None) -> None:
|
||||
async def command_clear(
|
||||
self, ctx: ApplicationContext, amount: int, user: User = None
|
||||
) -> None:
|
||||
try:
|
||||
check: Callable[[Message], bool] = (lambda msg: True) if user is None else (lambda msg: msg.author.id == user.id)
|
||||
check: Callable[[Message], bool] = (
|
||||
(lambda msg: True) if user is None else (lambda msg: msg.author.id == user.id)
|
||||
)
|
||||
|
||||
purged_messages: List[Message] = await ctx.channel.purge(limit=amount, check=check)
|
||||
|
||||
await ctx.respond(
|
||||
embed=self.bot.create_embed(description=f"Deleted {len(purged_messages)} message(s)."),
|
||||
embed=self.bot.create_embed(
|
||||
description=f"Deleted {len(purged_messages)} message(s)."
|
||||
),
|
||||
ephemeral=True,
|
||||
delete_after=3.0,
|
||||
)
|
||||
except Forbidden:
|
||||
await ctx.respond(
|
||||
embed=self.bot.create_embed_error("Missing permissions", description="The bot does not have permission to delete messages. Please, allow the bot to delete messages and try again."),
|
||||
embed=self.bot.create_embed_error(
|
||||
"Missing permissions",
|
||||
description="The bot does not have permission to delete messages. Please, allow the bot to delete messages and try again.",
|
||||
),
|
||||
ephemeral=True,
|
||||
)
|
||||
except Exception as exc:
|
||||
await ctx.respond(
|
||||
embed=self.bot.create_embed_error("Something went wrong", description=f"Could not delete messages:\n```\n{exc}\n```"),
|
||||
embed=self.bot.create_embed_error(
|
||||
"Something went wrong",
|
||||
description=f"Could not delete messages:\n```\n{exc}\n```",
|
||||
),
|
||||
ephemeral=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
def setup(bot: PycordBot) -> None:
|
||||
bot.add_cog(CogAdmin(bot))
|
||||
|
||||
@@ -7,9 +7,10 @@ from zoneinfo import ZoneInfo
|
||||
from discord import (
|
||||
ApplicationContext,
|
||||
Interaction,
|
||||
InteractionContextType,
|
||||
OptionChoice,
|
||||
SlashCommandGroup,
|
||||
option, InteractionContextType,
|
||||
option,
|
||||
)
|
||||
from discord.ext import commands
|
||||
from libbot.i18n import _, in_every_locale
|
||||
@@ -26,7 +27,9 @@ class CogConsent(commands.Cog):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.bot: PycordBot = client
|
||||
|
||||
command_group: SlashCommandGroup = SlashCommandGroup("consent", "Consent management", contexts={InteractionContextType.guild})
|
||||
command_group: SlashCommandGroup = SlashCommandGroup(
|
||||
"consent", "Consent management", contexts={InteractionContextType.guild}
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _get_scope_choices() -> List[OptionChoice]:
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import logging
|
||||
from logging import Logger
|
||||
|
||||
from discord import ApplicationContext, SlashCommandGroup, option, InteractionContextType
|
||||
from discord import (
|
||||
ApplicationContext,
|
||||
InteractionContextType,
|
||||
SlashCommandGroup,
|
||||
option,
|
||||
)
|
||||
from discord.ext import commands
|
||||
|
||||
from javelina.classes.pycord_bot import PycordBot
|
||||
@@ -13,7 +18,9 @@ class CogData(commands.Cog):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.bot: PycordBot = client
|
||||
|
||||
command_group: SlashCommandGroup = SlashCommandGroup("data", "Data management", contexts={InteractionContextType.guild})
|
||||
command_group: SlashCommandGroup = SlashCommandGroup(
|
||||
"data", "Data management", contexts={InteractionContextType.guild}
|
||||
)
|
||||
|
||||
# /data checkout
|
||||
# Export all user data in a ZIP archive
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import logging
|
||||
from logging import Logger
|
||||
|
||||
from discord import ApplicationContext, SlashCommandGroup, User, option, InteractionContextType
|
||||
from discord import (
|
||||
ApplicationContext,
|
||||
InteractionContextType,
|
||||
SlashCommandGroup,
|
||||
User,
|
||||
option,
|
||||
)
|
||||
from discord.ext import commands
|
||||
|
||||
from javelina.classes.errors import WalletInsufficientFunds
|
||||
@@ -17,7 +23,9 @@ class CogWallet(commands.Cog):
|
||||
def __init__(self, client: PycordBot):
|
||||
self.bot: PycordBot = client
|
||||
|
||||
command_group: SlashCommandGroup = SlashCommandGroup("wallet", "Wallet management", contexts={InteractionContextType.guild})
|
||||
command_group: SlashCommandGroup = SlashCommandGroup(
|
||||
"wallet", "Wallet management", contexts={InteractionContextType.guild}
|
||||
)
|
||||
|
||||
@command_group.command(
|
||||
name="balance",
|
||||
|
||||
Reference in New Issue
Block a user