Exemplo n.º 1
0
import asyncio
import discord
import cogs.globals as glbls
import cogs.utils.api as api
import cogs.utils.configloader as configloader
import random
import cogs.globals as glbls
from discord.ext import commands
from discord.ext.commands import bot
import os
discordConfig = configloader.getDiscordValues()


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

    @commands.command()
    async def servers(self, ctx):
        servers = api.getAvailablePublicServers()
        servers.extend(api.getListedServers())
        strServers = ""
        for server in servers:
            strServers = strServers + "\n**ID:** {}\n**Name:** {}\n **Country:** :flag_{}:\n".format(
                server['id'], server['display_name'], server['flag'].lower())
        embed = discord.Embed(description=strServers, color=0x03f0fc)
        await ctx.send(embed=embed)
        return

    @commands.command()
    async def select(self, ctx, arg):
Exemplo n.º 2
0
import peewee as pw
import cogs.utils.configloader as config
import random
import string

databaseValues = config.getDatabaseValues()
discordValues = config.getDiscordValues()
try:
    db = pw.MySQLDatabase(database=databaseValues['dbname'],
                          host=databaseValues['host'],
                          port=int(databaseValues['port']),
                          user=databaseValues['user'],
                          passwd=databaseValues['password'])
except:
    raise ImportError("Database is not instantiated!")


def get_available_public_servers():
    servers = Game_server.select().where((Game_server.public_server == 1)
                                         & (Game_server.in_use == 0)).get()
    return servers


def get_server(server_id):
    server = Game_server.get(server_id)
    return server


def create_match(user_id, server_id, veto_first):
    api_key = ''.join(random.SystemRandom().choice(string.ascii_uppercase +
                                                   string.digits)