예제 #1
0
async def on_ready():
    print(f"-----\n{bot.user.name} Online\n-----\nPrefix: {bot.prefix}\n-----")
    status = secret_file["status"]
    if status == "online":
        await bot.change_presence(activity=discord.Game(
            name=f"{bot.prefix}help in {len(bot.guilds)} servers"))
    elif status == "idle":
        await bot.change_presence(activity=discord.Game(
            name=f"{bot.prefix}help in {len(bot.guilds)} servers"),
                                  status=discord.Status.idle)
    elif status == "streaming":
        await bot.change_presence(activity=discord.Streaming(
            name=f"{bot.prefix}help", url="https://twitch.tv/discord"))

    bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(str(bot.connection_url))
    bot.db = bot.mongo["lyfe"]
    if status == "online":
        bot.db = bot.mongo["lyfe"]
    elif status == "idle":
        bot.db = bot.mongo["lyfebeta"]
    else:
        bot.db = bot.mongo["lyfeaqua"]
    bot.inventories = Document(bot.db, "inventories")
    bot.items = Document(bot.db, "items")
    bot.trades = Document(bot.db, "trades")
    bot.playershops = Document(bot.db, "playershops")
    bot.cooldowns = Document(bot.db, "cooldowns")
    print("Initialized database\n-----")
예제 #2
0
async def on_ready():
    member_count_all = 0
    print("Bot online!")
    print("Logged into " + bot.user.name + "#" + bot.user.discriminator + "!")
    print("___________\n")
    print("Bot Stats")
    print("\n___________")
    print(f"{str(len(bot.guilds))} Servers")

    bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(mongodbtoken)
    bot.db = bot.mongo["core"]
    bot.config = Document(bot.db, "info")
    bot.warningData = Document(bot.db, "warnings")
    bot.prefixData = Document(bot.db, "prefixes")
    for document in await bot.config.get_all():
        print(document)

    for guild in bot.guilds:
        if await bot.config.find_by_id(guild.id) == None:
            await bot.config.insert({
                "_id": guild.id,
                "debug_mode": False,
                "announcement_channel": "announcements",
                "verification_role": "Verified",
                "manualverification": False,
                "link_automoderation": False
            })

    for guild in bot.guilds:
        if await bot.prefixData.find_by_id(guild.id) == None:
            await bot.prefixData.insert({"_id": guild.id, "prefix": "!"})

    for document in await bot.prefixData.get_all():
        print(document)

    print(f"{member_count_all} Members")
    warningDataUpdate.start()
    status_change.start()

    bot.load_extension('cogs.dbl')
    bot.load_extension('cogs.help')
    bot.load_extension('cogs.utility')
    bot.load_extension('cogs.fun')
    bot.load_extension('cogs.verify')
    bot.load_extension('cogs.creator')
    bot.load_extension('cogs.info')
    bot.load_extension('cogs.config')
    bot.load_extension('cogs.lcrp')
    bot.load_extension('cogs.announce')
    bot.load_extension('cogs.moderation')

    for guild in bot.guilds:

        print(f"{str(guild.id)} | {str(guild.name)}")
예제 #3
0
async def get_prefix(client, message):
    mongo = motor.motor_asyncio.AsyncIOMotorClient(mongodbtoken)
    db = mongo["core"]
    prefixes = Document(db, "prefixes")
    if await prefixes.find_by_id(message.guild.id) == None:
        return "!"
    else:
        dataset = await prefixes.find_by_id(message.guild.id)
        return dataset["prefix"]
예제 #4
0
async def on_ready():
    print('Logged in as', bot.user.name)
    print("Bot ID:", bot.user.id)
    print('Bot latency:', bot.latency * 1000, 2)
    print('Running discord.py version ' + discord.__version__)
    bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(str(bot.connection_url))
    bot.db = bot.mongo["menudocs"]
    bot.config = Document(bot.db, "config")
    bot.mutes = Document(bot.db, "mutes")

    print("Initialized Database\n-----")
    for document in await bot.config.get_all():
        print(document)

    currentMutes = await bot.mutes.get_all()
    for mute in currentMutes:
        bot.muted_users[mute["_id"]] = mute

    print(bot.muted_users)
예제 #5
0
파일: main.py 프로젝트: MenuDocs/Pyro
async def dbbackup(ctx):
    """Back up the database"""
    await ctx.send("https://giphy.com/gifs/christmas-3P0oEX5oTmrkY")

    backup_db = motor.motor_asyncio.AsyncIOMotorClient(mongo_url).backup
    backup_config = Document(backup_db, "config")
    backup_keywords = Document(backup_db, "keywords")
    backup_quiz = Document(backup_db, "quiz")
    backup_code = Document(backup_db, "code")
    backup_quiz_answers = Document(backup_db, "quizAnswers")
    backup_starboard = Document(backup_db, "starboard")

    for item in await bot.config.get_all():
        await backup_config.upsert(item)

    for item in await bot.keywords.get_all():
        await backup_keywords.upsert(item)

    for item in await bot.quiz.get_all():
        await backup_quiz.upsert(item)

    for item in await bot.code.get_all():
        await backup_code.upsert(item)

    for item in await bot.quiz_answers.get_all():
        await backup_quiz_answers.upsert(item)

    for item in await bot.starboard.get_all():
        await backup_starboard.upsert(item)

    await ctx.send(
        "https://giphy.com/gifs/deliverance-vN3fMMSAmVwoo\n\n*Database backup complete*"
    )
예제 #6
0
async def on_ready():
    print(
        f"-----\nLogged in as: {bot.user.name} : {bot.user.id}\n-----\nMy current prefix is: {bot.DEFAULTPREFIX}\n-----"
    )
    await bot.change_presence(activity=discord.Game(
        name=f"My Prefix Is ~ | Use It To Interact With Me"))

    bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(str(bot.connection_url))
    bot.db = bot.mongo["prefixes"]
    bot.config = Document(bot.db, "config")
    bot.mutes = Document(bot.db, "mutes")
    bot.logchannel = Document(bot.db, "logs")

    for document in await bot.config.get_all():
        print(document)

    currentMutes = await bot.mutes.get_all()
    for mute in currentMutes:
        bot.muted_users[mute["_id"]] = mute

    print(bot.muted_users)
    print("Initialized Database\n-----")
예제 #7
0
파일: bot.py 프로젝트: knifeworm/Milo-Bot
    except Exception as e:
        result = "".join(format_exception(e, e, e.__traceback__))

    pager = Pag(
        timeout=100,
        entries=[result[i:i + 2000] for i in range(0, len(result), 2000)],
        length=1,
        prefix="```py\n",
        suffix="```")

    await pager.start(ctx)


if __name__ == "__main__":
    # When running this file, if it is the 'main' file
    # I.E its not being imported from another python file run this
    bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(str(bot.connection_url))
    bot.db = bot.mongo["menudocs"]
    bot.config = Document(bot.db, "config")
    bot.mutes = Document(bot.db, "mutes")
    bot.invites = Document(bot.db, "invites")
    bot.command_usage = Document(bot.db, "command_usage")
    bot.warns = Document(bot.db, "warns")
    bot.reaction_roles = Document(bot.db, "reaction_roles")

    for file in os.listdir(cwd + "/cogs"):
        if file.endswith(".py") and not file.startswith("_"):
            bot.load_extension(f"cogs.{file[:-3]}")

    bot.run(bot.config_token)
예제 #8
0
async def on_ready():
    await bot.change_presence(activity=discord.Game(name=f"I am The Farmer"))
    bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(str(bot.connection_url))
    bot.db = bot.mongo["Smurfs"]
    bot.config = Document(bot.db, "testing")
예제 #9
0
파일: main.py 프로젝트: MenuDocs/Pyro
        await backup_quiz_answers.upsert(item)

    for item in await bot.starboard.get_all():
        await backup_starboard.upsert(item)

    await ctx.send(
        "https://giphy.com/gifs/deliverance-vN3fMMSAmVwoo\n\n*Database backup complete*"
    )


# Load all extensions
if __name__ == "__main__":
    # Database initialization
    bot.db = motor.motor_asyncio.AsyncIOMotorClient(mongo_url).pyro

    bot.config = Document(bot.db, "config")
    bot.keywords = Document(bot.db, "keywords")
    bot.quiz = Document(bot.db, "quiz")
    bot.code = Document(bot.db, "code")
    bot.quiz_answers = Document(bot.db, "quizAnswers")
    bot.starboard = Document(bot.db, "starboard")
    bot.tictactoe = Document(bot.db, "tictactoe")

    for ext in os.listdir("./cogs/"):
        if ext.endswith(".py") and not ext.startswith("_"):
            try:
                bot.load_extension(f"cogs.{ext[:-3]}")
            except Exception as e:
                logger.error(
                    "An error occurred while loading ext cogs.{}: {}".format(
                        ext[:-3], e))