Esempio n. 1
0
async def main(args=None,
               command=None,
               bot=None,
               prefix=None,
               msg=None,
               message=None,
               guildid=None,
               guild=None,
               memid=None,
               mem=None,
               mentions=None,
               channel=None,
               user=None,
               game=None,
               gamedata=None,
               dbguild=None,
               msgcontent=None,
               ids=None):
    await channel.trigger_typing()
    if mentions:
        u1 = user

        u2 = db.get_member(mentions[0])

        if u2["team"] == u1["team"]:
            team = db.get_team(u1["team"])
            if team != None and team["owner"] == u1["id"]:
                db.pull_team(team["id"], "members", u2["id"])
                db.update_user(u2["id"], "team", None)
                await channel.send('<@!' + str(u2["id"]) +
                                   '>, you have been kicked from team ' +
                                   team["name"] + '!')
                await bot.get_channel(config.LOGCHANNEL
                                      ).send("`Kick Team: " + u2["name"] +
                                             " " + team["id"] + " " +
                                             str(guildid) + "`")
            else:
                await channel.send('You do not own a team!')
        else:
            await channel.send("That user isn't in your team!")
    else:
        await channel.send('You must mention another user!')
Esempio n. 2
0
async def main(args=None, command=None, bot=None, prefix=None, msg=None, message=None, guildid=None, guild=None, memid=None, mem=None, mentions=None, channel=None, user=None, game=None, gamedata=None, dbguild=None, msgcontent=None, ids=None):
	if mentions:
		if len(args) > 2:
			u1 = user
			u2 = db.get_member(mentions[0])

			try:
				amount = int(args[2])
				amount = abs(amount)
				if not amount > u1["xp"]:
					if u1["id"] == u2["id"]:
						await channel.send("Paying yourself may make you feel richer, but you won't actually be any richer.")
					else:
						db.inc_user(u1["id"],"xp",-amount)
						db.inc_user(u2["id"],"xp", amount)
						await channel.send("<@!"+str(u1["id"])+">, you have paid <@!"+str(u2["id"])+"> "+str(amount)+" tokens!")
				else:
					await channel.send("You dont have enough tokens!")
			except Exception as e:
				await channel.send("You must specify a valid amount of tokens!")
		else:
			await channel.send('You must specify how many tokens you want to give!')
	else:
		await channel.send('You must specify who you want to give tokens to!')
Esempio n. 3
0
async def main(args=None,
               command=None,
               bot=None,
               prefix=None,
               msg=None,
               message=None,
               guildid=None,
               guild=None,
               memid=None,
               mem=None,
               mentions=None,
               channel=None,
               user=None,
               game=None,
               gamedata=None,
               dbguild=None,
               msgcontent=None,
               ids=None):
    if game == None:
        if mentions:

            game2 = db.get_game(mentions[0].id)

            if game2 == None:
                if mentions[0].id == memid:
                    await channel.send(
                        "You can't connect with yourself in this way. Why not take a walk?"
                    )

                else:
                    await channel.send(
                        str(mentions[0].mention) +
                        ", you are being challenged to a chess game by " +
                        str(mem.mention) + "! Use `" + prefix +
                        "accept` to accept the challenge or `" + prefix +
                        "decline` to decline the challenge!")

                    try:

                        def check(message):
                            return message.author == mentions[0] and (
                                message.content == prefix + 'accept'
                                or message.content == prefix + 'decline')

                        resp = await bot.wait_for('message',
                                                  check=check,
                                                  timeout=50)

                        if resp.content == prefix + 'accept':
                            await resp.channel.trigger_typing()
                            u1 = db.get_member(mem)
                            u2 = db.get_member(mentions[0])

                            db.new_game(chess.Board().fen(), u1["id"],
                                        u2["id"])

                            await channel.send('The game has started! Type ' +
                                               prefix +
                                               'board to see the board!')

                            await bot.get_channel(
                                config.LOGCHANNEL
                            ).send("`Create Game: " + str(u1["name"]) + " " +
                                   str(u2["name"]) + " " + str(guildid) + "`")
                            if config.MOTD == "":
                                await bot.change_presence(
                                    activity=discord.Game(
                                        name=str(db.games.find().count()) +
                                        " games!"),
                                    status=discord.Status.online)
                            else:
                                await bot.change_presence(
                                    activity=discord.Game(name=config.MOTD),
                                    status=discord.Status.online)

                            db.inc_guild(guildid, "games", 1)
                        elif resp.content == prefix + 'decline':
                            await channel.send(
                                "You have declined the game request!")
                    except:
                        await channel.send("The request has timed out!")

            else:
                await channel.send(
                    'That user is currently in a game with another person!')
        else:
            await channel.send('You must mention another user!')
    else:
        await channel.send('You are already in a game! Resign it with ' +
                           prefix + 'resign')
Esempio n. 4
0
async def on_message(message):

    try:
        try:
            dbguild = db.retrieve_guild(message.guild)
            prefix = dbguild["prefix"]
        except:
            prefix = "|"
        if str(message.author.id) != str(
                config.ID
        ) and not message.author.bot and message.content.startswith(prefix):

            msg = message
            msgcontent = msg.content
            mem = msg.author
            memid = mem.id
            user = db.get_member(mem)
            if user["blacklisted"]:
                return
            guild = msg.guild
            try:
                guildid = guild.id
                guildname = guild.name
                guildowner = guild.owner
            except:
                pass
            channel = msg.channel
            mentions = msg.mentions

            gamedata = db.get_game(memid)
            game = None
            ids = None
            if gamedata != None:
                game = chess.Board(fen=gamedata["fen"])
                ids = (gamedata["1"], gamedata["2"])

            args = ' '.join(msgcontent.strip(prefix).split()).split()
            try:
                command = args[0]
            except:
                return

            if command in ALIASES and ALIASES[command] != None:
                await channel.trigger_typing()
                await ALIASES[command](args=args,
                                       command=command,
                                       bot=bot,
                                       prefix=prefix,
                                       msg=msg,
                                       message=msg,
                                       guildid=guildid,
                                       guild=guild,
                                       memid=memid,
                                       mem=mem,
                                       mentions=mentions,
                                       channel=channel,
                                       user=user,
                                       game=game,
                                       gamedata=gamedata,
                                       msgcontent=msgcontent,
                                       ids=ids)

                if guild != None:
                    await bot.get_channel(
                        config.LOGCHANNEL
                    ).send("```Member: " + str(mem) + "\nMember ID: " +
                           str(memid) + "\nGuild: " + str(guild) +
                           "\nGuild ID: " + str(guildid) + "\n\nCommmand: " +
                           str(command) + "\n\nArgs: " + str(args) + "```")
                else:
                    await bot.get_channel(
                        config.LOGCHANNEL
                    ).send("```Member: " + str(mem) + "\nMember ID: " +
                           str(memid) + "\n\nCommmand: " + str(command) +
                           "\n\nArgs: " + str(args) + "```")

    except Exception as E:
        await bot.get_channel(
            config.ERRORCHANNEL
        ).send("```python\n" + str(traceback.format_exc()) + "```\n" + "`" +
               str(message.author) + ": " + message.content + "`")
Esempio n. 5
0
async def on_member_update(before, after):
    user = db.get_member(after)
    if str(after) != user["name"]:
        db.update_user(user["id"], "name", str(after))
Esempio n. 6
0
async def main(args=None,
               command=None,
               bot=None,
               prefix=None,
               msg=None,
               message=None,
               guildid=None,
               guild=None,
               memid=None,
               mem=None,
               mentions=None,
               channel=None,
               user=None,
               game=None,
               gamedata=None,
               dbguild=None,
               msgcontent=None,
               ids=None):
    if mentions:
        user = db.get_member(mentions[0])

        team = db.get_team(user["team"])
        if team == None:
            await channel.send(mentions[0].mention + " is not in a team!")

    else:
        if len(args) > 1:
            team = db.get_team(args[1])
            if team == None:
                await channel.send('Team not found!')
        else:
            user = user

            team = db.get_team(user["team"])
            if team == None:
                await channel.send("You are not in a team!")

    if team != None:
        em = discord.Embed()
        em.title = team["name"]
        if "image" in team:
            em.set_thumbnail(url=team["image"])
        else:
            em.set_thumbnail(
                url=
                "https://cdn4.iconfinder.com/data/icons/glyph-seo-icons/48/business-strategy-512.png"
            )
        em.colour = discord.Colour(4623620)
        em.type = "rich"
        if team["bio"] != None:
            em.description = team["bio"]
        em.add_field(name="Members",
                     value=', '.join(
                         [db.get_user(i)["name"] for i in team["members"]]),
                     inline=False)
        em.add_field(name="Owner",
                     value=db.get_user(team["owner"])["name"],
                     inline=True)
        em.add_field(name="Shards", value=team["cur"], inline=True)
        em.add_field(name="Wins", value=team["wins"], inline=True)
        em.add_field(name="Losses", value=team["loss"], inline=True)
        try:
            em.add_field(
                name="W/G",
                value=str(round(team["wins"] / team["games"], 2) * 100) + "%",
                inline=True)
        except:
            em.add_field(name="W/G", value="None", inline=True)

        em.add_field(name="Draws", value=team["draws"], inline=True)
        em.add_field(name="Games", value=team["games"], inline=True)

        await channel.send(embed=em)
Esempio n. 7
0
async def main(args=None,
               command=None,
               bot=None,
               prefix=None,
               msg=None,
               message=None,
               guildid=None,
               guild=None,
               memid=None,
               mem=None,
               mentions=None,
               channel=None,
               user=None,
               game=None,
               gamedata=None,
               dbguild=None,
               msgcontent=None,
               ids=None):

    if mentions:
        member = await bot.get_user_info(mentions[0].id)
        user = db.get_member(mentions[0])

    else:
        member = await bot.get_user_info(memid)
        user = user

    em = discord.Embed()
    em.title = member.name
    em.set_thumbnail(url=member.avatar_url)
    em.colour = discord.Colour(user["color"])
    em.type = "rich"
    if user["bio"] != None:
        em.description = user["bio"]
    em.add_field(name="Elo", value=user["elo"], inline=True)
    em.add_field(name="Tokens", value=user["xp"], inline=True)
    em.add_field(name="Wins", value=user["wins"], inline=True)
    em.add_field(name="Losses", value=user["loss"], inline=True)
    try:
        em.add_field(name="W/G",
                     value=str(round(user["wins"] / user["games"], 2) * 100) +
                     "%",
                     inline=True)
    except:
        em.add_field(name="W/G", value="None", inline=True)
    em.add_field(name="Draws", value=user["draws"], inline=True)
    em.add_field(name="Games", value=user["games"], inline=True)
    em.add_field(name="Votes", value=user["votes"], inline=True)
    if user["team"] != None:
        team = db.get_team(user["team"])
        em.add_field(name="Team", value=team["name"], inline=True)
    else:
        em.add_field(name="Team", value="None", inline=True)

    if len(user["badges"]) > 0:
        em.add_field(name="Badges",
                     value=' '.join([config.BADGES[i]
                                     for i in user["badges"]]),
                     inline=True)
    else:
        em.add_field(name="Badges", value="None", inline=True)
    await channel.send(embed=em)
Esempio n. 8
0
async def main(args=None,
               command=None,
               bot=None,
               prefix=None,
               msg=None,
               message=None,
               guildid=None,
               guild=None,
               memid=None,
               mem=None,
               mentions=None,
               channel=None,
               user=None,
               game=None,
               gamedata=None,
               dbguild=None,
               msgcontent=None,
               ids=None):
    if mentions:
        u1 = user

        u2 = db.get_member(mentions[0])

        if u2["team"] == None:
            team = db.get_team(u1["team"])
            if team != None and team["owner"] == u1["id"]:
                if len(team["members"]) < config.MAXTEAMSIZE:
                    await channel.send(
                        str(mentions[0].mention) +
                        ", you are being invited to " + str(mem.mention) +
                        "'s team! Use `" + prefix + "join` to join or `" +
                        prefix + "decline` to decline the request!")
                    try:

                        def check(message):
                            return message.author == mentions[0] and (
                                message.content == prefix + 'join'
                                or message.content == prefix + 'decline')

                        resp = await bot.wait_for('message',
                                                  check=check,
                                                  timeout=50)
                        if resp.content == prefix + 'join':
                            team = db.get_team(u1["team"])
                            if len(team["members"]) < config.MAXTEAMSIZE:
                                await resp.channel.trigger_typing()
                                db.push_team(team["id"], "members", u2["id"])
                                db.update_user(u2["id"], "team", team["id"])
                                await resp.channel.send("<@!" + str(u2["id"]) +
                                                        "> has joined team " +
                                                        team["name"] + "!")
                                await bot.get_channel(
                                    config.LOGCHANNEL
                                ).send("`Join Team: " + u2["name"] + " " +
                                       team["id"] + " " + str(guildid) + "`")
                            else:
                                await resp.channel.send('That team is full!')
                        elif resp.content == prefix + 'decline':
                            await resp.channel.send(
                                'You have declined the request!')
                    except:
                        await channel.send("The request has timed out!")
                else:
                    await channel.send('Your team is full!')
            else:
                await channel.send('You do not own a team!')
        else:
            await channel.send('That user is already in a team!')
    else:
        await channel.send('You must mention another user!')