Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
reques6e committed Apr 5, 2024
1 parent 14e9448 commit 807548a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
30 changes: 22 additions & 8 deletions cogs/private_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import nextcord
import datetime
from config import *
from loguru import logger

connection = sqlite3.connect('db/pr.db')
cursor = connection.cursor()
Expand Down Expand Up @@ -198,7 +199,7 @@ def __init__(self, bot: commands.Bot):

@commands.Cog.listener()
async def on_ready(self):
print("Private Rooms - work")
logger.success('Ког Private Rooms был успешно подключен к боту')
cursor.execute("""CREATE TABLE IF NOT EXISTS privates(
ownerid BIGINT,
voicename TEXT,
Expand All @@ -208,8 +209,20 @@ async def on_ready(self):
perms BIGINT);
""")
connection.commit()

guild = self.bot.get_guild(guild_id)
if guild:
category = nextcord.utils.get(guild.categories, id=category_id)
if category and isinstance(category, nextcord.CategoryChannel):
for channel in guild.voice_channels:
if channel.id != create_private_chan_id:
await channel.delete()
logger.warning('Обнаружил лишний голосовой канал {} ({})'.format(channel.name, channel.id))
else:
print("Guild not found.")

strt_send = guild.get_channel(private_control_id)

emb = nextcord.Embed(title='Управление приватными комнатами',
description='> Жми следующие кнопки, чтобы настроить свою комнату',
color=nextcord.Colour.from_rgb(47, 49, 54))
Expand Down Expand Up @@ -530,10 +543,14 @@ async def author_info_callback(interaction: nextcord.Interaction):
m = [message async for message in strt_send.history(limit=1)]
ch_channel = self.bot.get_channel(private_control_id)
try:
message = await ch_channel.fetch_message(create_private_chan_id)
message = await ch_channel.fetch_message(message_id)
await message.edit(embed=emb, view=view)

logger.success('Сообщение с id {} было успешно изменено.'.format(message_id))
except:
await strt_send.send(embed=emb, view=view)
message = await strt_send.send(embed=emb, view=view)

logger.warning('Сообщение с id {} не было изенено, отправляю новую панель с message id {}'.format(message_id, message.id))


@commands.Cog.listener()
Expand Down Expand Up @@ -572,10 +589,7 @@ async def on_voice_state_update(self, member: nextcord.Member, before: nextcord.
cursor.execute("UPDATE privates SET perms = Null WHERE voiceid = {}".format(private_voice.id))
connection.commit()

# @nextcord.slash_command(name='say', description='Оставить коментарий')
# async def sdvsdfsdsdfdsfds(self, interaction: nextcord.Interaction):
# ch = self.bot.get_channel(1180419074472292382)
# await ch.send('Voice')
# Девелопер Reques6e666 оставил свой след... 05.04.24

def setup(bot):
bot.add_cog(Voice(bot))
bot.add_cog(Voice(bot))
9 changes: 5 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
token = 'your_token_here'
guild_id = 0
token = 'your_bot_token_here'
guild_id = 0 # ID Сервера

private_control_id = 0
create_private_chan_id = 0
category_id = 0 # ID Категории в котором находятся private_control_id и create_private_chan_id
private_control_id = 0 # Текстовый канал для отпавки панели управления приватной комнаты
create_private_chan_id = 0 # Голосовой канал для создания приватной комнаты
message_id = 0 # ДЛЯ ВТОРОГО ЗАПУСКА БОТА!

emoji1 = '<:vip:1180438222082420818>' # передать владельца
Expand Down
11 changes: 10 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import nextcord
import os
import sys

from nextcord.ext import commands
from config import token
from loguru import logger

logger.remove()
logger.add(sys.stderr, format='<white>{time:HH:mm:ss}</white>'
' | <level>{level: <8}</level>'
' | <cyan>{line}</cyan>'
' - <white>{message}</white>')

intents = nextcord.Intents.all()
bot = commands.Bot(command_prefix='?', intents=intents)
bot.remove_command('help')


logger.info('Начинаю загружать коги...')
for fn in os.listdir("./cogs"):
if fn.endswith(".py"):
bot.load_extension(f"cogs.{fn[:-3]}")
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SERVICE_FILE="/etc/systemd/system/privateroomsbot.service"

SERVICE_CONTENT="[Unit]
Description=TicketBot
Description=PrivateRoomBot
After=network.target
[Service]
Expand Down

0 comments on commit 807548a

Please sign in to comment.