Sorted, formatted, removed unused imports
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from os import getpid, system
|
||||
from typing import Union
|
||||
|
||||
from discord import ApplicationContext, Embed, User, slash_command, option
|
||||
from discord import ApplicationContext, Embed, User, option, slash_command
|
||||
from discord import utils as ds_utils
|
||||
from discord.ext import commands
|
||||
|
||||
from classes.holo_user import HoloUser
|
||||
from enums.colors import Color
|
||||
from modules.scheduled import scheduler
|
||||
from modules.utils import config_get
|
||||
from modules.utils_sync import config_get_sync, guild_name
|
||||
from modules.scheduled import scheduler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
from discord import ApplicationContext, Embed, option
|
||||
from discord.abc import GuildChannel
|
||||
from discord import utils as ds_utils
|
||||
from discord.abc import GuildChannel
|
||||
from discord.commands import SlashCommandGroup
|
||||
from discord.ext import commands
|
||||
|
||||
from classes.holo_user import HoloUser
|
||||
from enums.colors import Color
|
||||
from modules.database import col_users
|
||||
from modules.utils import config_get
|
||||
from modules.utils_sync import config_get_sync, guild_name
|
||||
from modules.database import col_users
|
||||
|
||||
|
||||
class CustomChannels(commands.Cog):
|
||||
@@ -17,8 +17,9 @@ class CustomChannels(commands.Cog):
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_guild_channel_delete(self, channel: GuildChannel):
|
||||
col_users.find_one_and_update({"customchannel": channel.id}, {"$set": {"customchannel": None}})
|
||||
|
||||
col_users.find_one_and_update(
|
||||
{"customchannel": channel.id}, {"$set": {"customchannel": None}}
|
||||
)
|
||||
|
||||
customchannel = SlashCommandGroup("customchannel", "Керування особистим каналом")
|
||||
|
||||
@@ -97,7 +98,9 @@ class CustomChannels(commands.Cog):
|
||||
):
|
||||
holo_user_ctx = HoloUser(ctx.user)
|
||||
|
||||
custom_channel = ds_utils.get(ctx.guild.channels, id=holo_user_ctx.customchannel)
|
||||
custom_channel = ds_utils.get(
|
||||
ctx.guild.channels, id=holo_user_ctx.customchannel
|
||||
)
|
||||
if custom_channel is None:
|
||||
await ctx.respond(
|
||||
embed=Embed(
|
||||
@@ -129,7 +132,9 @@ class CustomChannels(commands.Cog):
|
||||
guild_ids=[config_get_sync("guild")],
|
||||
)
|
||||
@option("confirm", description="Підтвердження операції")
|
||||
async def customchannel_remove_cmd(self, ctx: ApplicationContext, confirm: bool = False):
|
||||
async def customchannel_remove_cmd(
|
||||
self, ctx: ApplicationContext, confirm: bool = False
|
||||
):
|
||||
holo_user_ctx = HoloUser(ctx.user)
|
||||
|
||||
if holo_user_ctx.customchannel is not None:
|
||||
|
@@ -7,19 +7,20 @@ from modules.utils import config_get
|
||||
|
||||
|
||||
class Logger(commands.Cog):
|
||||
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message: Message):
|
||||
|
||||
if (message.author != self.client.user) and (message.author.bot == False) and (message.author.system == False):
|
||||
|
||||
if (
|
||||
(message.author != self.client.user)
|
||||
and (message.author.bot == False)
|
||||
and (message.author.system == False)
|
||||
):
|
||||
if col_users.find_one({"user": message.author.id}) is None:
|
||||
user = {}
|
||||
defaults = await config_get("user", "defaults")
|
||||
|
||||
|
||||
user["user"] = message.author.id
|
||||
|
||||
for key in defaults:
|
||||
@@ -29,21 +30,33 @@ class Logger(commands.Cog):
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_member_join(self, member: Member):
|
||||
welcome_chan = ds_utils.get(
|
||||
self.client.get_guild(await config_get("guild")).channels,
|
||||
id=await config_get("welcome", "channels", "text"),
|
||||
)
|
||||
rules_chan = ds_utils.get(
|
||||
self.client.get_guild(await config_get("guild")).channels,
|
||||
id=await config_get("rules", "channels", "text"),
|
||||
)
|
||||
|
||||
welcome_chan = ds_utils.get(self.client.get_guild(await config_get("guild")).channels, id=await config_get("welcome", "channels", "text"))
|
||||
rules_chan = ds_utils.get(self.client.get_guild(await config_get("guild")).channels, id=await config_get("rules", "channels", "text"))
|
||||
|
||||
if (member != self.client.user) and (member.bot == False) and (member.system == False):
|
||||
|
||||
await welcome_chan.send(content=(await config_get("welcome", "messages")).format(mention=member.mention, rules=rules_chan.mention))
|
||||
if (
|
||||
(member != self.client.user)
|
||||
and (member.bot == False)
|
||||
and (member.system == False)
|
||||
):
|
||||
await welcome_chan.send(
|
||||
content=(await config_get("welcome", "messages")).format(
|
||||
mention=member.mention, rules=rules_chan.mention
|
||||
)
|
||||
)
|
||||
|
||||
if col_users.find_one({"user": member.id}) is None:
|
||||
user = {}
|
||||
defaults = await config_get("user", "defaults")
|
||||
|
||||
|
||||
user["user"] = member.id
|
||||
|
||||
for key in defaults:
|
||||
user[key] = defaults[key]
|
||||
|
||||
col_users.insert_one(document=user)
|
||||
col_users.insert_one(document=user)
|
||||
|
Reference in New Issue
Block a user