Пример #1
0
async def run():
    # Create a Dictionary under the name help attrs
    help_attrs = dict(hidden=True)
    # Log into the database
    credentials = {
        "user": config.dbname,
        "password": config.dbpass,
        "database": config.database,
        "host": "127.0.0.1",
    }
    db = await asyncpg.create_pool(**credentials)

    # Add tables if they don't exist
    await db.execute(
        "CREATE TABLE IF NOT EXISTS warnings(serverid bigint, userid bigint, warnings int);"
    )
    await db.execute(
        "CREATE TABLE IF NOT EXISTS modlogs(serverid bigint, caseid bigint, casenumber int, casetype varchar, target bigint, moderator bigint, reason varchar);"
    )
    await db.execute(
        "CREATE TABLE IF NOT EXISTS adminpanel(serverid bigint, joins int, leaves int, embeds int, nsfw int, automod int, modlog int);"
    )
    await db.execute(
        "CREATE TABLE IF NOT EXISTS automod(serverid bigint, autorole int, adblock int, lockdown int, antispam int, owo int, uwu int, ignorerole int, actionlog int);"
    )
    await db.execute(
        "CREATE TABLE IF NOT EXISTS idstore(serverid bigint, joinmsg varchar, leavemsg varchar, joinchan bigint, leavechan bigint, modlogchan bigint, ignorerolerole bigint, autorolerole bigint, actionlogchan bigint);"
    )
    await db.execute(
        "CREATE TABLE IF NOT EXISTS tags(serverid bigint, tagname varchar, tagtext varchar);"
    )
    await db.execute(
        "CREATE TABLE IF NOT EXISTS userbal(userid bigint, money bigint);")

    # Make the client
    bot = Bot(command_prefix=config.prefix,
              pm_help=True,
              help_attrs=help_attrs,
              db=db)
    # Remove help command
    bot.remove_command("help")
    # Get the cogs, send a startup message
    try:
        print("Logging in...")
        for file in os.listdir("cogs"):
            if file.endswith(".py"):
                name = file[:-3]
                bot.load_extension(f"cogs.{name}")
        await bot.start(config.token)
    except KeyboardInterrupt:
        await db.close()
        await bot.logout()
Пример #2
0
async def run():
    help_attrs = dict(hidden=True)
    credentials = {
        "user": config.dbname,
        "password": config.dbpass,
        "database": config.database,
        "host": "127.0.0.1",
    }
    db = await asyncpg.create_pool(**credentials)

    await db.execute(
        "CREATE TABLE IF NOT EXISTS warnings(userid bigint, warnings int);")
    await db.execute(
        "CREATE TABLE IF NOT EXISTS artstats(userid bigint, upvotes int);")
    await db.execute(
        "CREATE TABLE IF NOT EXISTS sketchdaily(code int, artist varchar, idea varchar);"
    )

    bot = Bot(
        command_prefix=config.prefix,
        prefix=config.prefix,
        pm_help=True,
        help_attrs=help_attrs,
        formatter=HelpFormat(),
        db=db,
    )
    try:
        print("Logging in...")
        for file in os.listdir("cogs"):
            if file.endswith(".py"):
                name = file[:-3]
                bot.load_extension(f"cogs.{name}")
        await bot.start(config.token)
    except KeyboardInterrupt:
        await db.close()
        await bot.logout()
Пример #3
0
from discord.ext.commands import HelpFormatter
from data import Bot
from utils import permissions, default

config = default.get("config.json")
description = """
Project Management Bot
Made by Johan Tan based on starter bot code by AlexFlipnote
"""


class HelpFormat(HelpFormatter):
    async def format_help_for(self, context, command_or_bot):
        if permissions.can_react(context):
            await context.message.add_reaction(chr(0x2709))

        return await super().format_help_for(context, command_or_bot)


print("Logging in...")
help_attrs = dict(hidden=True)
bot = Bot(command_prefix=config.prefix, prefix=config.prefix, pm_help=True, help_attrs=help_attrs, formatter=HelpFormat())

for file in os.listdir("cogs"):
    if file.endswith(".py"):
        name = file[:-3]
        bot.load_extension(f"cogs.{name}")

bot.run(config.discord_token)
Пример #4
0
        except discord.Forbidden:
            destination = await self.get_destination(no_pm=True)
            await destination.send(
                ":x: | Nie mogę wysłać ci helpa, ponieważ masz zablokowane prywatne wiadomości :("
            )


print("Uruchamianie...")
help_attrs = dict(hidden=True)
bot = Bot(command_prefix=config.prefix,
          prefix=config.prefix,
          pm_help=True,
          help_attrs=help_attrs,
          formatter=HelpFormat())

for file in os.listdir("modules"):
    if file.endswith(".py"):
        name = file[:-3]
        bot.load_extension(f"modules.{name}")


@bot.event
async def on_ready(self):
    print(f'Ready: {self.bot.user} | Servers: {len(self.bot.guilds)}')
    await self.bot.change_presence(activity=discord.Game(
        type=0, name=self.config.playing),
                                   status=discord.Status.online)


bot.run(config.token)