added logging

This commit is contained in:
bacon
2024-03-08 10:52:45 +03:00
parent fc18ade975
commit 7ad57f9fe8
7 changed files with 18 additions and 12 deletions

1
.gitignore vendored
View File

@@ -10,3 +10,4 @@
/venv/ /venv/
/fun_and_admin_bot.egg-info/ /fun_and_admin_bot.egg-info/
/qodana.yaml /qodana.yaml
/.YMcache/

2
bot.py
View File

@@ -74,7 +74,7 @@ async def _cog_opt(inter: disnake.ApplicationCommandInteraction, current: str, w
@slash_cogs.error @slash_cogs.error
async def cogs_error(inter, what_do): async def cogs_error(inter: disnake.ApplicationCommandInteraction, what_do):
await inter.response.send_message('Error', ephemeral=True) await inter.response.send_message('Error', ephemeral=True)
logger.error(f'User {inter.author} tries to use cogs func\n{what_do}\n') logger.error(f'User {inter.author} tries to use cogs func\n{what_do}\n')

View File

@@ -75,7 +75,7 @@ class Admin(commands.Cog, name='Admin'):
] ]
) )
@commands.has_permissions(administrator=True) @commands.has_permissions(administrator=True)
async def set_guest_role(self, inter, role): async def set_guest_role(self, inter: disnake.ApplicationCommandInteraction, role):
await write_json(inter.guild.id, "guest_role", role.id) await write_json(inter.guild.id, "guest_role", role.id)
await inter.response.send_message(f"Set up bot role to: `{role.name}`", ephemeral=True) await inter.response.send_message(f"Set up bot role to: `{role.name}`", ephemeral=True)
@@ -94,7 +94,7 @@ class Admin(commands.Cog, name='Admin'):
] ]
) )
@commands.has_permissions(administrator=True) @commands.has_permissions(administrator=True)
async def slash_set_prefix(self, inter, prefix: str): async def slash_set_prefix(self, inter: disnake.ApplicationCommandInteraction, prefix: str):
await write_json(inter.guild.id, "prefix", prefix) await write_json(inter.guild.id, "prefix", prefix)
await inter.response.send_message(f"Prefix set to: `{prefix}`", ephemeral=True) await inter.response.send_message(f"Prefix set to: `{prefix}`", ephemeral=True)
@@ -107,7 +107,7 @@ class Admin(commands.Cog, name='Admin'):
] ]
) )
@commands.has_permissions(administrator=True) @commands.has_permissions(administrator=True)
async def set_trigger_role(self, inter, role): async def set_trigger_role(self, inter: disnake.ApplicationCommandInteraction, role):
await write_json(inter.guild.id, "tigger_role", role.id) await write_json(inter.guild.id, "tigger_role", role.id)
await inter.response.send_message(f"Role to trigger set to : `{role.name}`", ephemeral=True) await inter.response.send_message(f"Role to trigger set to : `{role.name}`", ephemeral=True)
@@ -127,7 +127,7 @@ class Admin(commands.Cog, name='Admin'):
@set_bot_role.error @set_bot_role.error
@set_trigger_role.error @set_trigger_role.error
@slash_set_prefix.error @slash_set_prefix.error
async def set_prefix_error(self, inter, prefix): async def set_prefix_error(self, inter: disnake.ApplicationCommandInteraction, prefix):
await inter.response.send_message("You don`t have permissions", ephemeral=True) await inter.response.send_message("You don`t have permissions", ephemeral=True)
logger.error(prefix) logger.error(prefix)
@@ -151,7 +151,7 @@ class Admin(commands.Cog, name='Admin'):
description="Set channel which iterate with bot", description="Set channel which iterate with bot",
) )
async def set_bot_channel(self, inter, channel: str): async def set_bot_channel(self, inter: disnake.ApplicationCommandInteraction, channel: str):
await write_json(inter.guild.id, await write_json(inter.guild.id,
"channel", "channel",
disnake.utils.find(lambda d: d.name == channel, inter.guild.channels).id) disnake.utils.find(lambda d: d.name == channel, inter.guild.channels).id)

View File

@@ -23,7 +23,7 @@ class Audio(commands.Cog, name='Audio'):
before: VoiceState, before: VoiceState,
after: VoiceState): after: VoiceState):
if before.channel is None and not member.bot: if before.channel is None and not member.bot:
logger.info(f'Coneccted {member.name} to {member.voice}') logger.info(f'Coneccted {member.name} to {after.channel.name}')
if any('Escape from Tarkov' in str(user.activity) for user in after.channel.members): if any('Escape from Tarkov' in str(user.activity) for user in after.channel.members):
logger.info('Skip playing by Game') logger.info('Skip playing by Game')
else: else:

View File

@@ -1,5 +1,6 @@
import disnake
from disnake import Option
from disnake.ext import commands from disnake.ext import commands
from lib import logger from lib import logger
@@ -11,6 +12,12 @@ class Testing(commands.Cog, name='Testing'):
async def on_ready(self): async def on_ready(self):
logger.info(f'Cog {__name__.split(".")[1]} is ready!.') logger.info(f'Cog {__name__.split(".")[1]} is ready!.')
@commands.slash_command(name='play', description='play audio test from yandex.music', options=[
Option(name='search', description='seach track/artist')
])
async def play(self, inter: disnake.ApplicationCommandInteraction, audio):
pass
def setup(bot): # an extension must have a setup function def setup(bot): # an extension must have a setup function
bot.add_cog(Testing(bot)) # adding a cog bot.add_cog(Testing(bot)) # adding a cog

View File

@@ -21,7 +21,7 @@ class General(commands.Cog):
Option("user", "Specify any user", OptionType.user), Option("user", "Specify any user", OptionType.user),
] ]
) )
async def info(self, inter, user=None): async def info(self, inter: disnake.ApplicationCommandInteraction, user=None):
audio = None audio = None
user = user or inter.author user = user or inter.author
_user = DBReader(inter.guild.id) _user = DBReader(inter.guild.id)

View File

@@ -1,6 +1,4 @@
disnake[audio] disnake[audio]
psutil psutil
pymediainfo
pyNaCl
python-dotenv python-dotenv
ffmpeg-python setuptools