Example #1
0
 async def load(self, ctx):
     """
     Load config from `config.toml`
     """
     global Config
     importlib.reload(Config_module)
     Config = Config_module.Config()
     await ctx.send(Messages.config_loaded)
Example #2
0
 def load_config(self):
     global Config
     importlib.reload(Config_module)
     Config = Config_module.Config()
Example #3
0
import discord
from discord.ext import commands
import re
import os
import toml
from datetime import datetime
import importlib

import utils
import config.app_config as Config_module
from config.messages import Messages

Config = Config_module.Config()


class DynamicConfig(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.check(utils.is_bot_admin)
    @commands.group(pass_context=True)
    async def config(self, ctx):
        """
        Group of commands for dynamicaly changing config
        """
        if ctx.invoked_subcommand is None:
            await ctx.send(utils.get_command_group_signature(ctx))

    @config.command(name="set", brief=Messages.config_set_brief)
    async def set_value(self, ctx, key=None, *value):
        """
Example #4
0
"""

import math
from functools import cached_property
from typing import Iterable, Union, Callable

import discord
from discord.ext.commands import Context
from discord.ext.menus import PageSource, Menu
from sqlalchemy.orm.query import Query
from sqlalchemy.schema import Table

import utils
from config import app_config

config = app_config.Config()

DatabasePage = Iterable[Table]


class DatabaseIteratorPageSource(PageSource):
    """A data source from sqlalchemy database query.

    This page source does not handle any sort of formatting, leaving it up
    to the user. To do so, implement the :meth:`format_page` method.
    """
    def __init__(self, query: Query, per_page=10):
        """
        query: :class:`Query`
            The query which will be realized to poll for database items.
            It MUST NOT have `.offset`, `.limit` or `.slice` already applied on it.