WIP: libbot 4.0.0 adoption
This commit is contained in:
parent
a753918432
commit
162898f5eb
@ -3,7 +3,7 @@ from typing import Any, Union, Dict
|
|||||||
|
|
||||||
from bson import ObjectId
|
from bson import ObjectId
|
||||||
from discord import User, Member
|
from discord import User, Member
|
||||||
from libbot import config_get
|
from libbot.utils import config_get
|
||||||
|
|
||||||
from errors import UserNotFoundError
|
from errors import UserNotFoundError
|
||||||
from modules.database import col_warnings, sync_col_users, sync_col_warnings, col_users
|
from modules.database import col_warnings, sync_col_users, sync_col_warnings, col_users
|
||||||
|
@ -13,8 +13,7 @@ from discord import (
|
|||||||
)
|
)
|
||||||
from discord import utils as ds_utils
|
from discord import utils as ds_utils
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from libbot import config_get
|
from libbot.utils import config_get
|
||||||
from libbot.sync import config_get as sync_config_get
|
|
||||||
|
|
||||||
from classes.holo_bot import HoloBot
|
from classes.holo_bot import HoloBot
|
||||||
from enums import Color
|
from enums import Color
|
||||||
@ -117,7 +116,7 @@ class Admin(commands.Cog):
|
|||||||
@slash_command(
|
@slash_command(
|
||||||
name="clear",
|
name="clear",
|
||||||
description="Видалити деяку кількість повідомлень в каналі",
|
description="Видалити деяку кількість повідомлень в каналі",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
@option("amount", description="Кількість")
|
@option("amount", description="Кількість")
|
||||||
@option("user", description="Користувач", default=None)
|
@option("user", description="Користувач", default=None)
|
||||||
@ -182,7 +181,7 @@ class Admin(commands.Cog):
|
|||||||
@slash_command(
|
@slash_command(
|
||||||
name="reboot",
|
name="reboot",
|
||||||
description="Перезапустити бота",
|
description="Перезапустити бота",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
async def reboot_cmd(self, ctx: ApplicationContext) -> None:
|
async def reboot_cmd(self, ctx: ApplicationContext) -> None:
|
||||||
await ctx.defer(ephemeral=True)
|
await ctx.defer(ephemeral=True)
|
||||||
|
@ -6,8 +6,7 @@ from discord import utils as ds_utils
|
|||||||
from discord.abc import GuildChannel
|
from discord.abc import GuildChannel
|
||||||
from discord.commands import SlashCommandGroup
|
from discord.commands import SlashCommandGroup
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from libbot import config_get
|
from libbot.utils import config_get
|
||||||
from libbot.sync import config_get as sync_config_get
|
|
||||||
|
|
||||||
from classes.holo_bot import HoloBot
|
from classes.holo_bot import HoloBot
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
@ -35,7 +34,7 @@ class CustomChannels(commands.Cog):
|
|||||||
@custom_channel_group.command(
|
@custom_channel_group.command(
|
||||||
name="get",
|
name="get",
|
||||||
description="Отримати персональний текстовий канал",
|
description="Отримати персональний текстовий канал",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
@option("name", description="Назва каналу")
|
@option("name", description="Назва каналу")
|
||||||
@option("reactions", description="Дозволити реакції")
|
@option("reactions", description="Дозволити реакції")
|
||||||
@ -122,7 +121,7 @@ class CustomChannels(commands.Cog):
|
|||||||
@custom_channel_group.command(
|
@custom_channel_group.command(
|
||||||
name="edit",
|
name="edit",
|
||||||
description="Змінити параметри особистого каналу",
|
description="Змінити параметри особистого каналу",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
@option("name", description="Назва каналу")
|
@option("name", description="Назва каналу")
|
||||||
@option("reactions", description="Дозволити реакції")
|
@option("reactions", description="Дозволити реакції")
|
||||||
@ -167,7 +166,7 @@ class CustomChannels(commands.Cog):
|
|||||||
@custom_channel_group.command(
|
@custom_channel_group.command(
|
||||||
name="remove",
|
name="remove",
|
||||||
description="Відібрати канал, знищуючи його, та частково повернути кошти",
|
description="Відібрати канал, знищуючи його, та частково повернути кошти",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
@option("confirm", description="Підтвердження операції")
|
@option("confirm", description="Підтвердження операції")
|
||||||
async def custom_channel_remove_cmd(
|
async def custom_channel_remove_cmd(
|
||||||
|
10
cogs/data.py
10
cogs/data.py
@ -9,9 +9,7 @@ from discord import ApplicationContext, Embed, File, option, Role, TextChannel
|
|||||||
from discord import utils as ds_utils
|
from discord import utils as ds_utils
|
||||||
from discord.commands import SlashCommandGroup
|
from discord.commands import SlashCommandGroup
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from libbot import config_get
|
from libbot.utils import config_get, json_write
|
||||||
from libbot.sync import config_get as sync_config_get
|
|
||||||
from libbot.sync import json_write as sync_json_write
|
|
||||||
|
|
||||||
from classes.holo_bot import HoloBot
|
from classes.holo_bot import HoloBot
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
@ -31,7 +29,7 @@ class Data(commands.Cog):
|
|||||||
@data.command(
|
@data.command(
|
||||||
name="export",
|
name="export",
|
||||||
description="Експортувати дані",
|
description="Експортувати дані",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"kind", description="Тип даних, які треба експортувати", choices=["Користувачі"]
|
"kind", description="Тип даних, які треба експортувати", choices=["Користувачі"]
|
||||||
@ -94,14 +92,14 @@ class Data(commands.Cog):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
sync_json_write(users, Path(f"tmp/{uuid}"))
|
json_write(users, Path(f"tmp/{uuid}"))
|
||||||
|
|
||||||
await ctx.respond(file=File(Path(f"tmp/{uuid}"), filename="users.json"))
|
await ctx.respond(file=File(Path(f"tmp/{uuid}"), filename="users.json"))
|
||||||
|
|
||||||
@data.command(
|
@data.command(
|
||||||
name="migrate",
|
name="migrate",
|
||||||
description="Мігрувати всіх користувачів до бази",
|
description="Мігрувати всіх користувачів до бази",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"kind", description="Тип даних, які треба експортувати", choices=["Користувачі"]
|
"kind", description="Тип даних, які треба експортувати", choices=["Користувачі"]
|
||||||
|
@ -2,8 +2,7 @@ import logging
|
|||||||
|
|
||||||
from discord import ApplicationContext, Embed, User, option, slash_command
|
from discord import ApplicationContext, Embed, User, option, slash_command
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from libbot import config_get
|
from libbot.utils import config_get
|
||||||
from libbot.sync import config_get as sync_config_get
|
|
||||||
|
|
||||||
from classes.holo_bot import HoloBot
|
from classes.holo_bot import HoloBot
|
||||||
from modules.utils_sync import guild_name
|
from modules.utils_sync import guild_name
|
||||||
@ -19,12 +18,12 @@ class Fun(commands.Cog):
|
|||||||
@slash_command(
|
@slash_command(
|
||||||
name="action",
|
name="action",
|
||||||
description="Провести над користувачем РП дію",
|
description="Провести над користувачем РП дію",
|
||||||
guild_ids=[sync_config_get("guild")],
|
guild_ids=[config_get("guild")],
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"type",
|
"type",
|
||||||
description="Тип дії, яку хочете провести з користувачем",
|
description="Тип дії, яку хочете провести з користувачем",
|
||||||
choices=sync_config_get("actions").keys(),
|
choices=config_get("actions").keys(),
|
||||||
)
|
)
|
||||||
@option("user", description="Користувач")
|
@option("user", description="Користувач")
|
||||||
async def action_cmd(self, ctx: ApplicationContext, type: str, user: User) -> None:
|
async def action_cmd(self, ctx: ApplicationContext, type: str, user: User) -> None:
|
||||||
|
@ -3,7 +3,7 @@ from typing import Dict, Any, Union
|
|||||||
from discord import Member, Message, TextChannel
|
from discord import Member, Message, TextChannel
|
||||||
from discord import utils as ds_utils
|
from discord import utils as ds_utils
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from libbot import config_get
|
from libbot.utils import config_get
|
||||||
|
|
||||||
from classes.holo_bot import HoloBot
|
from classes.holo_bot import HoloBot
|
||||||
from modules.database import col_users
|
from modules.database import col_users
|
||||||
|
@ -3,7 +3,7 @@ from logging import Logger
|
|||||||
|
|
||||||
from discord import Activity, ActivityType
|
from discord import Activity, ActivityType
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from libbot import config_get
|
from libbot.utils import config_get
|
||||||
|
|
||||||
from classes.holo_bot import HoloBot
|
from classes.holo_bot import HoloBot
|
||||||
|
|
||||||
|
4
main.py
4
main.py
@ -4,7 +4,7 @@ from logging import Logger
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from discord import LoginFailure, Intents
|
from discord import LoginFailure, Intents
|
||||||
from libbot.sync import config_get as sync_config_get
|
from libbot.utils import config_get
|
||||||
|
|
||||||
from classes.holo_bot import HoloBot
|
from classes.holo_bot import HoloBot
|
||||||
from modules.scheduler import scheduler
|
from modules.scheduler import scheduler
|
||||||
@ -38,7 +38,7 @@ def main() -> None:
|
|||||||
client.load_extension("cogs")
|
client.load_extension("cogs")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client.run(sync_config_get("bot_token", "bot"))
|
client.run(config_get("bot_token", "bot"))
|
||||||
except LoginFailure as exc:
|
except LoginFailure as exc:
|
||||||
logger.error("Provided bot token is invalid: %s", exc)
|
logger.error("Provided bot token is invalid: %s", exc)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
|
|
||||||
from async_pymongo import AsyncClient, AsyncCollection, AsyncDatabase
|
from async_pymongo import AsyncClient, AsyncCollection, AsyncDatabase
|
||||||
from libbot.sync import config_get as sync_config_get
|
from libbot.utils import config_get
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
from pymongo.synchronous.collection import Collection
|
from pymongo.synchronous.collection import Collection
|
||||||
from pymongo.synchronous.database import Database
|
from pymongo.synchronous.database import Database
|
||||||
|
|
||||||
db_config: Dict[str, Any] = sync_config_get("database")
|
db_config: Dict[str, Any] = config_get("database")
|
||||||
|
|
||||||
con_string: str = (
|
con_string: str = (
|
||||||
"mongodb://{0}:{1}/{2}".format(
|
"mongodb://{0}:{1}/{2}".format(
|
||||||
|
@ -5,6 +5,6 @@ requests>=2.32.2
|
|||||||
aiofiles~=24.1.0
|
aiofiles~=24.1.0
|
||||||
apscheduler>=3.10.0
|
apscheduler>=3.10.0
|
||||||
async_pymongo==0.1.11
|
async_pymongo==0.1.11
|
||||||
libbot[speed,pycord]==3.3.1
|
libbot[speed,pycord]==4.0.0
|
||||||
ujson~=5.10.0
|
ujson~=5.10.0
|
||||||
WaifuPicsPython==0.2.0
|
WaifuPicsPython==0.2.0
|
Loading…
Reference in New Issue
Block a user