mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Changing to pycord
This commit is contained in:
55
main.py
55
main.py
@@ -1,38 +1,49 @@
|
||||
from discord import Intents, Client
|
||||
from random import choices
|
||||
import string
|
||||
from discord.bot import Bot
|
||||
from discord import Intents
|
||||
from Music.MusicBot import VulkanBot
|
||||
from os import listdir
|
||||
from Config.Configs import Configs
|
||||
from discord.ext.commands import Bot
|
||||
|
||||
|
||||
class VulkanInitializer:
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, willListen: bool) -> None:
|
||||
self.__config = Configs()
|
||||
self.__intents = Intents.default()
|
||||
self.__intents.message_content = True
|
||||
self.__intents.members = True
|
||||
self.__bot = self.__create_bot()
|
||||
self.__bot = self.__create_bot(willListen)
|
||||
self.__add_cogs(self.__bot)
|
||||
|
||||
def __create_bot(self) -> Client:
|
||||
bot = Bot(command_prefix=self.__config.BOT_PREFIX,
|
||||
pm_help=True,
|
||||
case_insensitive=True,
|
||||
intents=self.__intents)
|
||||
bot.remove_command('help')
|
||||
def getBot(self) -> VulkanBot:
|
||||
return self.__bot
|
||||
|
||||
def __create_bot(self, willListen: bool) -> VulkanBot:
|
||||
if willListen:
|
||||
prefix = self.__config.BOT_PREFIX
|
||||
else:
|
||||
prefix = ''.join(choices(string.ascii_uppercase + string.digits, k=4))
|
||||
|
||||
bot = VulkanBot(command_prefix=prefix,
|
||||
pm_help=True,
|
||||
case_insensitive=True,
|
||||
intents=self.__intents)
|
||||
return bot
|
||||
|
||||
def __add_cogs(self, bot: Client) -> None:
|
||||
for filename in listdir(f'./{self.__config.COMMANDS_PATH}'):
|
||||
if filename.endswith('.py'):
|
||||
bot.load_extension(f'{self.__config.COMMANDS_PATH}.{filename[:-3]}')
|
||||
def __add_cogs(self, bot: Bot) -> None:
|
||||
try:
|
||||
for filename in listdir(f'./{self.__config.COMMANDS_PATH}'):
|
||||
if filename.endswith('.py'):
|
||||
print(f'Loading {filename}')
|
||||
bot.load_extension(f'{self.__config.COMMANDS_PATH}.{filename[:-3]}')
|
||||
|
||||
def run(self) -> None:
|
||||
if self.__config.BOT_TOKEN == '':
|
||||
print('DEVELOPER NOTE -> Token not found')
|
||||
exit()
|
||||
|
||||
self.__bot.run(self.__config.BOT_TOKEN, bot=True, reconnect=True)
|
||||
bot.load_extension(f'DiscordCogs.MusicCog')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
vulkan = VulkanInitializer()
|
||||
vulkan.run()
|
||||
initializer = VulkanInitializer(willListen=True)
|
||||
vulkanBot = initializer.getBot()
|
||||
vulkanBot.startBot()
|
||||
|
||||
Reference in New Issue
Block a user