Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nixxoq committed Nov 8, 2023
2 parents 3232d38 + 806890f commit 31dc72e
Show file tree
Hide file tree
Showing 15 changed files with 1,010 additions and 717 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<<<<<<< HEAD
0.3.1:
[Database]: fixed bug in BackupsDatabase. Re-implement base class
[Backups]: some changes, backups now work

=======
>>>>>>> 806890f7f3011613a74d6e889d19da9ca56ca3b0
0.3:
Updated base database, logger

Expand Down
224 changes: 112 additions & 112 deletions src/bot.py
Original file line number Diff line number Diff line change
@@ -1,112 +1,112 @@
import logging
import os
import sys
import traceback

import disnake
from disnake.ext import commands

from src.cogs.TicketsCog import SetupTicketSettings
from .utils import misc
from .utils.help import CustomHelpCommand
from .utils.misc import get_prefix, is_command_disabled


# from disnake.ext.ipc import Server


class Bot(commands.Bot):
"""The base class of Synth bot."""

def __init__(self) -> None:
super(Bot, self).__init__(
help_command=CustomHelpCommand(),
command_prefix=misc.bot_get_guild_prefix,
intents=disnake.Intents.all(),
reload=True,
owner_ids=[
419159175009009675,
999682446675161148,
1167458549132181668,
],
)

# self.ipc = Server(self, secret_key=config.SECRET_IPC_KEY) # well... need talk about config
self.i18n.load("src/utils/locale")

def view_add(self):
views = [SetupTicketSettings()]
for view in views:
self.add_view(view)
logging.info(f"Loaded {view.id} view")

async def on_message(self, message: disnake.Message):
prefix = await get_prefix(message)

if message.content.startswith(prefix):
# TODO: blacklist

# check if command is disabled
command = message.content.split()[0][len(prefix) :]
result = await is_command_disabled(message=message, command=command)
if result:
return

return await self.process_commands(message=message)

# async def setup_hook(self):
# await self.ipc.start()

async def on_ready(self) -> None:
logging.info(
f"Invite link: https://discord.com/api/oauth2/authorize?client_id="
f"{self.user.id}&permissions=980937982&scope=bot%20applications.commands"
)
logging.debug(f"Connected to {self.user}")
for extension in os.listdir("src\\cogs"):
if extension.endswith(".py"):
try:
event_name = extension[:-3]
self.load_extension(f"src.cogs.{event_name}")
except (
commands.ExtensionNotFound,
commands.NoEntryPointError,
commands.ExtensionFailed,
commands.ExtensionError,
) as e:
logging.error(
f"\n\nFailed to load {extension}!\n{traceback.print_exception(e)}"
)
continue
finally:
logging.info(f"{extension} is loaded!")

for event in os.listdir("src\\events"):
if not event.endswith(".py"):
continue

try:
self.load_extension(f"src.events.{event[:-3]}")
except (
commands.ExtensionNotFound,
commands.NoEntryPointError,
commands.ExtensionFailed,
commands.ExtensionError,
) as e:
exc_type = e.__class__.__name__
exc_line = sys.exc_info()[2].tb_lineno
logging.error(
f"Failed to load {event}! {exc_type}: {str(e)}, line {exc_line}"
)
continue
finally:
logging.info(f"{event} event is loaded!")

await self.wait_until_ready()
await self.change_presence(
activity=disnake.Activity(
type=disnake.ActivityType.competing,
name=f">>help | v1.0.",
status=disnake.Status.idle,
)
)
import logging
import os
import sys
import traceback

import disnake
from disnake.ext import commands

from src.cogs.TicketsCog import SetupTicketSettings
from .utils import misc
from .utils.help import CustomHelpCommand
from .utils.misc import get_prefix, is_command_disabled


# from disnake.ext.ipc import Server


class Bot(commands.Bot):
"""The base class of Synth bot."""

def __init__(self) -> None:
super(Bot, self).__init__(
help_command=CustomHelpCommand(),
command_prefix=misc.bot_get_guild_prefix,
intents=disnake.Intents.all(),
reload=True,
owner_ids=[
419159175009009675,
999682446675161148,
1167458549132181668,
],
)

# self.ipc = Server(self, secret_key=config.SECRET_IPC_KEY) # well... need talk about config
self.i18n.load("src/utils/locale")

def view_add(self):
views = [SetupTicketSettings()]
for view in views:
self.add_view(view)
logging.info(f"Loaded {view.id} view")

async def on_message(self, message: disnake.Message):
prefix = await get_prefix(message)

if message.content.startswith(prefix):
# TODO: blacklist

# check if command is disabled
command = message.content.split()[0][len(prefix) :]
result = await is_command_disabled(message=message, command=command)
if result:
return

return await self.process_commands(message=message)

# async def setup_hook(self):
# await self.ipc.start()

async def on_ready(self) -> None:
logging.info(
f"Invite link: https://discord.com/api/oauth2/authorize?client_id="
f"{self.user.id}&permissions=980937982&scope=bot%20applications.commands"
)
logging.debug(f"Connected to {self.user}")
for extension in os.listdir("src\\cogs"):
if extension.endswith(".py"):
try:
event_name = extension[:-3]
self.load_extension(f"src.cogs.{event_name}")
except (
commands.ExtensionNotFound,
commands.NoEntryPointError,
commands.ExtensionFailed,
commands.ExtensionError,
) as e:
logging.error(
f"\n\nFailed to load {extension}!\n{traceback.print_exception(e)}"
)
continue
finally:
logging.info(f"{extension} is loaded!")

for event in os.listdir("src\\events"):
if not event.endswith(".py"):
continue

try:
self.load_extension(f"src.events.{event[:-3]}")
except (
commands.ExtensionNotFound,
commands.NoEntryPointError,
commands.ExtensionFailed,
commands.ExtensionError,
) as e:
exc_type = e.__class__.__name__
exc_line = sys.exc_info()[2].tb_lineno
logging.error(
f"Failed to load {event}! {exc_type}: {str(e)}, line {exc_line}"
)
continue
finally:
logging.info(f"{event} event is loaded!")

await self.wait_until_ready()
await self.change_presence(
activity=disnake.Activity(
type=disnake.ActivityType.competing,
name=f">>help | v1.0.",
status=disnake.Status.idle,
)
)
Loading

0 comments on commit 31dc72e

Please sign in to comment.