示例#1
0
 def write(dict=None):
     '''Writes to the core config document.'''
     client = MongoClient(base.db)
     collection = client['configs']['core']
     if dict == None:
         return console.error(
             'Invalid config provided. Argument must be a dict.')
     collection.find_one_and_update({"_id": "core"}, {"$set": dict})
     return console.log(f'New core config created successfully.')
示例#2
0
 def write(self, dict=None):
     '''Adds a new document or edits an already existing one located in the current config instance.'''
     if not self.instanced:
         return console.error(
             'Config must be instanced in order to use "write" function.')
     if dict == None:
         return console.error(
             'Invalid config value provided. Argument must be a dict.')
     self.collection.find_one_and_update({"_id": self.cog_name},
                                         {"$set": dict})
     return console.log(
         f'New config assigned to cog {self.cog_name} created successfully.'
     )
示例#3
0
class core():
    '''Config system for core parts of bot
    
    Seperate class to allow use of configs without instancing class'''
    def write(dict=None):
        '''Writes to the core config document.'''
        client = MongoClient(base.db)
        collection = client['configs']['core']
        if dict == None:
            return console.error(
                'Invalid config provided. Argument must be a dict.')
        collection.find_one_and_update({"_id": "core"}, {"$set": dict})
        return console.log(f'New core config created successfully.')

    def setup():
        '''Setup core config with default values.
        
        Called in core_config.py'''
        client = MongoClient(base.db)
        collection = client['configs']['core']
        collection.insert_one({
            "_id": "core",
            "prefix": ">",
            "color": "cb2ad6",
            "name": "botradical",
            "status": "botradical",
            "admin": [538534716337553410],
            "mod": [708012152383995935, 534602336643842048]
        })

        with open('config.json', 'r') as d:
            data = json.load(d)
            print(data)
            data.update({"setup": True})
            print(data)
        with open('config.json', 'w') as d:
            json.dump(data, d, indent=4)

    if not base.setup_bool:
        console.warn('Config has not been setup...')
        setup()
        console.log(
            'Successfully setup default config. Please change these values with the bots config command system. [>help]'
        )
    client = MongoClient(base.db)
    collection = client['configs']['core']
    get = collection.find_one({"_id": "core"})
示例#4
0
 async def initialize(self):
     await self.bot.wait_until_ready()
     console.log('Connected to discord.')
     console.log('Bot has started with no errors.')
示例#5
0
# BOTRADICAL IS A BOT FRAMEWORK DESIGNED BY NASHRADICAL
# ORIGINALLY DESIGNED FOR "EDEN NETWORK" AND "THE COSMOS"
# THIS FRAMEWORK IS FREE TO USE AND MODIFY

# DISCORD: "nashradical#1111"
# GITHUB: "https://github.com/nashradical"

from discord import Intents
from os import listdir
from discord.ext import commands
from modules.ext import console, embed_help
from modules.config import base, core

console.log('Starting Bot...')

intents = Intents.all()  # subscribe to all discord intents
bot = commands.Bot(
    command_prefix=core.get['prefix'],
    case_insensitive=True,
    help_command=embed_help(
    ),  # replace default help command with modules/ext/help.py
    intents=intents)

console.log('Loading Cogs...')

for filename in listdir('./modules/cogs'):
    bot.load_extension('modules.cogs.' + filename)
    print('           | Loaded ' + filename)
bot.load_extension('modules.start')

console.log('Connecting to Discord...')