Merge pull request 'v0.1.0-rc.1' (#5) from dev into main
Reviewed-on: #5
This commit is contained in:
commit
72ccaa04a4
@ -3,6 +3,7 @@ import logging
|
|||||||
from discord import ApplicationContext, Embed, User, option, slash_command
|
from discord import ApplicationContext, Embed, User, option, slash_command
|
||||||
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.pycord.classes import PycordBot
|
||||||
|
|
||||||
from enums.colors import Color
|
from enums.colors import Color
|
||||||
from modules.scheduled import scheduler
|
from modules.scheduled import scheduler
|
||||||
@ -13,7 +14,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Admin(commands.Cog):
|
class Admin(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client: PycordBot):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
# @slash_command(
|
# @slash_command(
|
||||||
@ -111,9 +112,12 @@ class Admin(commands.Cog):
|
|||||||
amount: int,
|
amount: int,
|
||||||
user: User,
|
user: User,
|
||||||
):
|
):
|
||||||
if ctx.user.id in await config_get("admins"):
|
if ctx.user.id in self.client.config["bot"]["owners"]:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"User {ctx.user.id} removed {amount} message(s) in {ctx.channel.id}"
|
"User %s removed %s message(s) in %s",
|
||||||
|
ctx.user.id,
|
||||||
|
amount,
|
||||||
|
ctx.channel.id,
|
||||||
)
|
)
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(description="Видаляю..."), ephemeral=True, delete_after=2.0
|
embed=Embed(description="Видаляю..."), ephemeral=True, delete_after=2.0
|
||||||
@ -126,7 +130,8 @@ class Admin(commands.Cog):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
f"User {guild_name(ctx.user)} tried to use /clear but permission denied"
|
"User %s tried to use /clear but permission denied",
|
||||||
|
guild_name(ctx.user),
|
||||||
)
|
)
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
@ -158,8 +163,8 @@ class Admin(commands.Cog):
|
|||||||
)
|
)
|
||||||
async def reboot_cmd(self, ctx: ApplicationContext):
|
async def reboot_cmd(self, ctx: ApplicationContext):
|
||||||
await ctx.defer(ephemeral=True)
|
await ctx.defer(ephemeral=True)
|
||||||
if ctx.user.id in await config_get("admins"):
|
if ctx.user.id in self.client.config["bot"]["owners"]:
|
||||||
logging.info(f"Calling shutdown initiated by {guild_name(ctx.user)}")
|
logging.info("Calling shutdown initiated by %s", guild_name(ctx.user))
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
title="Вимикаюсь...",
|
title="Вимикаюсь...",
|
||||||
@ -171,7 +176,8 @@ class Admin(commands.Cog):
|
|||||||
exit()
|
exit()
|
||||||
else:
|
else:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
f"User {guild_name(ctx.user)} tried to use /reboot but permission denied"
|
"User %s tried to use /reboot but permission denied",
|
||||||
|
guild_name(ctx.user),
|
||||||
)
|
)
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
@ -195,3 +201,7 @@ class Admin(commands.Cog):
|
|||||||
color=Color.fail,
|
color=Color.fail,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(client: PycordBot):
|
||||||
|
client.add_cog(Admin(client))
|
||||||
|
@ -2,6 +2,7 @@ import logging
|
|||||||
|
|
||||||
from discord import Cog, Message
|
from discord import Cog, Message
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from libbot.pycord.classes import PycordBot
|
||||||
|
|
||||||
from modules.database import col_analytics
|
from modules.database import col_analytics
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Analytics(commands.Cog):
|
class Analytics(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client: PycordBot):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
@Cog.listener()
|
@Cog.listener()
|
||||||
@ -54,3 +55,7 @@ class Analytics(commands.Cog):
|
|||||||
"attachments": attachments,
|
"attachments": attachments,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(client: PycordBot):
|
||||||
|
client.add_cog(Analytics(client))
|
||||||
|
@ -3,6 +3,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.pycord.classes import PycordBot
|
||||||
|
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
from enums.colors import Color
|
from enums.colors import Color
|
||||||
@ -12,7 +13,7 @@ from modules.utils_sync import config_get_sync, guild_name
|
|||||||
|
|
||||||
|
|
||||||
class CustomChannels(commands.Cog):
|
class CustomChannels(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client: PycordBot):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
@ -80,7 +81,7 @@ class CustomChannels(commands.Cog):
|
|||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
title="Помилка виконання",
|
title="Помилка виконання",
|
||||||
description=f"У вас вже є особистий канал.\nДля редагування каналу є `/customchannel edit` або просто відкрийте меню керування вашим каналом.",
|
description="У вас вже є особистий канал.\nДля редагування каналу є `/customchannel edit` або просто відкрийте меню керування вашим каналом.",
|
||||||
color=Color.fail,
|
color=Color.fail,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -105,7 +106,7 @@ class CustomChannels(commands.Cog):
|
|||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
title="Канал не знайдено",
|
title="Канал не знайдено",
|
||||||
description=f"Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
description="Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
||||||
color=Color.fail,
|
color=Color.fail,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -146,7 +147,7 @@ class CustomChannels(commands.Cog):
|
|||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
title="Канал не знайдено",
|
title="Канал не знайдено",
|
||||||
description=f"Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
description="Канал, вказаний як ваш, не існує. Можливо, його було вручну видалено раніше.",
|
||||||
color=Color.fail,
|
color=Color.fail,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -156,7 +157,7 @@ class CustomChannels(commands.Cog):
|
|||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
title="Підтвердження не надано",
|
title="Підтвердження не надано",
|
||||||
description=f"Для підтвердження операції додайте до команди параметр `confirm` зі значенням `True`.",
|
description="Для підтвердження операції додайте до команди параметр `confirm` зі значенням `True`.",
|
||||||
color=Color.fail,
|
color=Color.fail,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -166,7 +167,7 @@ class CustomChannels(commands.Cog):
|
|||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
title="Канал знищено",
|
title="Канал знищено",
|
||||||
description=f"Ви відмовились від каналу та видалили його.",
|
description="Ви відмовились від каналу та видалили його.",
|
||||||
color=Color.default,
|
color=Color.default,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -175,7 +176,11 @@ class CustomChannels(commands.Cog):
|
|||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
title="Помилка виконання",
|
title="Помилка виконання",
|
||||||
description=f"У вас немає особистого каналу.",
|
description="У вас немає особистого каналу.",
|
||||||
color=Color.fail,
|
color=Color.fail,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(client: PycordBot):
|
||||||
|
client.add_cog(CustomChannels(client))
|
||||||
|
26
cogs/data.py
26
cogs/data.py
@ -7,8 +7,9 @@ from discord import ApplicationContext, Embed, File, option
|
|||||||
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 classes.holo_user import HoloUser
|
from libbot.pycord.classes import PycordBot
|
||||||
|
|
||||||
|
from classes.holo_user import HoloUser
|
||||||
from enums.colors import Color
|
from enums.colors import Color
|
||||||
from modules.database import col_users
|
from modules.database import col_users
|
||||||
from modules.utils import config_get
|
from modules.utils import config_get
|
||||||
@ -18,7 +19,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Data(commands.Cog):
|
class Data(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client: PycordBot):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
data = SlashCommandGroup("data", "Керування даними користувачів")
|
data = SlashCommandGroup("data", "Керування даними користувачів")
|
||||||
@ -34,11 +35,11 @@ class Data(commands.Cog):
|
|||||||
async def data_export_cmd(self, ctx: ApplicationContext, kind: str):
|
async def data_export_cmd(self, ctx: ApplicationContext, kind: str):
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
holo_user = HoloUser(ctx.author)
|
holo_user = HoloUser(ctx.author)
|
||||||
if (ctx.user.id in await config_get("admins")) or (
|
if (ctx.user.id in self.client.config["bot"]["owners"]) or (
|
||||||
await holo_user.is_council(ctx.author)
|
await holo_user.is_council(ctx.author)
|
||||||
):
|
):
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Moderator {guild_name(ctx.user)} exported current users list"
|
"Moderator %s exported current users list", guild_name(ctx.user)
|
||||||
)
|
)
|
||||||
makedirs("tmp", exist_ok=True)
|
makedirs("tmp", exist_ok=True)
|
||||||
uuid = str(uuid4())
|
uuid = str(uuid4())
|
||||||
@ -63,7 +64,8 @@ class Data(commands.Cog):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"User {guild_name(ctx.user)} tried to use /export but permission denied"
|
"User %s tried to use /export but permission denied",
|
||||||
|
guild_name(ctx.user),
|
||||||
)
|
)
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
@ -99,11 +101,12 @@ class Data(commands.Cog):
|
|||||||
async def data_migrate_cmd(self, ctx: ApplicationContext, kind: str):
|
async def data_migrate_cmd(self, ctx: ApplicationContext, kind: str):
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
holo_user = HoloUser(ctx.author)
|
holo_user = HoloUser(ctx.author)
|
||||||
if (ctx.user.id in await config_get("admins")) or (
|
if (ctx.user.id in self.client.config["bot"]["owners"]) or (
|
||||||
await holo_user.is_council(ctx.author)
|
await holo_user.is_council(ctx.author)
|
||||||
):
|
):
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Moderator {guild_name(ctx.user)} started migration of all members to the database"
|
"Moderator %s started migration of all members to the database",
|
||||||
|
guild_name(ctx.user),
|
||||||
)
|
)
|
||||||
|
|
||||||
if kind == "Користувачі":
|
if kind == "Користувачі":
|
||||||
@ -121,7 +124,7 @@ class Data(commands.Cog):
|
|||||||
|
|
||||||
col_users.insert_one(document=user)
|
col_users.insert_one(document=user)
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Added DB record for user {member.id} during migration"
|
"Added DB record for user %s during migration", member.id
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
@ -133,7 +136,8 @@ class Data(commands.Cog):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"User {guild_name(ctx.user)} tried to use /migrate but permission denied"
|
"User %s tried to use /migrate but permission denied",
|
||||||
|
guild_name(ctx.user),
|
||||||
)
|
)
|
||||||
await ctx.respond(
|
await ctx.respond(
|
||||||
embed=Embed(
|
embed=Embed(
|
||||||
@ -157,3 +161,7 @@ class Data(commands.Cog):
|
|||||||
color=Color.fail,
|
color=Color.fail,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(client: PycordBot):
|
||||||
|
client.add_cog(Data(client))
|
||||||
|
15
cogs/fun.py
15
cogs/fun.py
@ -2,6 +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.pycord.classes import PycordBot
|
||||||
from WaifuPicsPython import WaifuAsync
|
from WaifuPicsPython import WaifuAsync
|
||||||
|
|
||||||
from modules.utils import config_get
|
from modules.utils import config_get
|
||||||
@ -13,7 +14,7 @@ wafiu_pics = WaifuAsync()
|
|||||||
|
|
||||||
|
|
||||||
class Fun(commands.Cog):
|
class Fun(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client: PycordBot):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(
|
||||||
@ -36,7 +37,13 @@ class Fun(commands.Cog):
|
|||||||
image = await wafiu_pics.sfw(action)
|
image = await wafiu_pics.sfw(action)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"User {guild_name(ctx.user)} ({ctx.user.id}) {action_verb} {guild_name(user)} ({user.id}) with image {image}"
|
"User %s (%s) %s %s (%s) with image %s",
|
||||||
|
guild_name(ctx.user),
|
||||||
|
ctx.user.id,
|
||||||
|
action_verb,
|
||||||
|
guild_name(user),
|
||||||
|
user.id,
|
||||||
|
image,
|
||||||
)
|
)
|
||||||
|
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
@ -46,3 +53,7 @@ class Fun(commands.Cog):
|
|||||||
embed.set_image(url=image)
|
embed.set_image(url=image)
|
||||||
|
|
||||||
await ctx.respond(embed=embed)
|
await ctx.respond(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(client: PycordBot):
|
||||||
|
client.add_cog(Fun(client))
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
from discord import Member, Message
|
from discord import Member, Message
|
||||||
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.pycord.classes import PycordBot
|
||||||
|
|
||||||
from modules.database import col_users
|
from modules.database import col_users
|
||||||
from modules.utils import config_get
|
from modules.utils import config_get
|
||||||
|
|
||||||
|
|
||||||
class Logger(commands.Cog):
|
class Logger(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client: PycordBot):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
@ -60,3 +61,7 @@ class Logger(commands.Cog):
|
|||||||
user[key] = defaults[key]
|
user[key] = defaults[key]
|
||||||
|
|
||||||
col_users.insert_one(document=user)
|
col_users.insert_one(document=user)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(client: PycordBot):
|
||||||
|
client.add_cog(Logger(client))
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
{
|
{
|
||||||
"token": "",
|
"locale": "en",
|
||||||
"owner": 0,
|
"debug": false,
|
||||||
"guild": 0,
|
"guild": 0,
|
||||||
"admins": [],
|
"bot": {
|
||||||
|
"owners": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"debug_guilds": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"bot_token": ""
|
||||||
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"type": "playing",
|
"type": "playing",
|
||||||
"message": "on your nerves"
|
"message": "on your nerves"
|
||||||
|
9
locale/en.json
Normal file
9
locale/en.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"flag": "🇬🇧",
|
||||||
|
"name": "English",
|
||||||
|
"codes": [
|
||||||
|
"en"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
9
locale/uk.json
Normal file
9
locale/uk.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"flag": "🇺🇦",
|
||||||
|
"name": "Українська",
|
||||||
|
"codes": [
|
||||||
|
"uk"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
19
main.py
19
main.py
@ -2,12 +2,6 @@ import logging
|
|||||||
|
|
||||||
from discord import Activity, ActivityType
|
from discord import Activity, ActivityType
|
||||||
|
|
||||||
from cogs.admin import Admin
|
|
||||||
from cogs.analytics import Analytics
|
|
||||||
from cogs.custom_channels import CustomChannels
|
|
||||||
from cogs.data import Data
|
|
||||||
from cogs.fun import Fun
|
|
||||||
from cogs.logger import Logger
|
|
||||||
from modules.client import client
|
from modules.client import client
|
||||||
from modules.scheduled import scheduler
|
from modules.scheduled import scheduler
|
||||||
from modules.utils import config_get
|
from modules.utils import config_get
|
||||||
@ -31,7 +25,7 @@ except ImportError:
|
|||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
logger.info(f"Logged in as {client.user}")
|
logger.info("Logged in as %s", client.user)
|
||||||
|
|
||||||
activity_type = await config_get("type", "status")
|
activity_type = await config_get("type", "status")
|
||||||
activity_message = await config_get("message", "status")
|
activity_message = await config_get("message", "status")
|
||||||
@ -63,16 +57,13 @@ async def on_ready():
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info(f"Set activity type to {activity_type} with message {activity_message}")
|
logger.info(
|
||||||
|
"Set activity type to %s with message %s", activity_type, activity_message
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
client.add_cog(Admin(client))
|
client.load_extension("cogs")
|
||||||
client.add_cog(Analytics(client))
|
|
||||||
client.add_cog(CustomChannels(client))
|
|
||||||
client.add_cog(Data(client))
|
|
||||||
client.add_cog(Fun(client))
|
|
||||||
client.add_cog(Logger(client))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from discord import Intents, Bot
|
from discord import Intents
|
||||||
|
from libbot.pycord.classes import PycordBot
|
||||||
|
|
||||||
intents = Intents().all()
|
intents = Intents().all()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
client = Bot(intents=intents)
|
client = PycordBot(intents=intents)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
aiofiles==23.1.0
|
aiofiles==23.2.1
|
||||||
apscheduler==3.10.1
|
apscheduler==3.10.4
|
||||||
py-cord[speed]==2.4.1
|
pymongo~=4.7.3
|
||||||
pymongo==4.3.3
|
requests~=2.32.3
|
||||||
requests==2.30.0
|
ujson~=5.10.0
|
||||||
ujson==5.7.0
|
|
||||||
WaifuPicsPython==0.2.0
|
WaifuPicsPython==0.2.0
|
||||||
|
--extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple
|
||||||
|
libbot[speed,pycord]==3.2.2
|
Loading…
Reference in New Issue
Block a user