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() team = db.get_team(user["team"]) if team != None and team["owner"] == user["id"]: if user["xp"] >= 800: db.inc_user(user["id"], "xp", -800) db.delete_team(team["id"]) await channel.send('Team ' + team["name"] + " has been disbanded!") await bot.get_channel(config.LOGCHANNEL ).send("`Disband Team: " + team["id"] + " " + str(guildid) + "`") else: await channel.send( "You do not have enough tokens to disband your team! 800T needed!" ) else: await channel.send('You do not own a team!')
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): u = user if u["team"] != None: team = db.get_team(u["team"]) if u["id"] == team["owner"]: await channel.send("As the team owner, you may not leave.") else: db.update_user(u["id"], "team", None) db.pull_team(u["team"], "members", u["id"]) await channel.send("You have left " + team["name"] + "!") await bot.get_channel(config.LOGCHANNEL ).send("`Leave Team: " + u["name"] + " " + team["id"] + " " + str(guildid) + "`") else: await channel.send("You are not in a team!")
def api_team(teamid): try: team = db.get_team(teamid) del team["_id"] return jsonify(team) except: return jsonify({'error': 'unknown'})
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 len(args) > 1: u = user if u["team"] != None: name = args[1].replace("@", "") if len(name) > 2 and len(name) < 17: if not name in db.teams.distinct('name'): if u["xp"] >= 200: team = db.get_team(u["team"]) db.inc_user(u["id"], "xp", -200) db.update_team(u["team"], "id", name) db.update_team(name, "name", name) for m in team["members"]: db.update_user(m, "team", name) await channel.send("Team " + team["name"] + " has been renamed to " + name + "!") await bot.get_channel( config.LOGCHANNEL ).send("`Rename Team: " + team["name"] + " " + name + "`") else: await channel.send( "You do not have enough tokens to rename your team! 200T needed!" ) else: await channel.send("That team name is already taken!") else: await channel.send( "The team name must be in between 3 and 16 characters long (and one word)!" ) else: await channel.send("You do not own a team!") else: await channel.send("You must specify a team name!")
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 len(args) > 1: u = user team = db.get_team(u["team"]) if team != None and team["owner"] == u["id"]: bio = ' '.join(args[1:]) if len(bio)<=250: db.update_team(team["id"],"bio",bio) await channel.send("Team bio set!") else: await channel.send('Your bio is too long! (Over 250 characters)') else: await channel.send('You do not own a team!') else: await channel.send('You must specify a bio!')
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!')
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)
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)
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!')
async def reward_game(winner, loser, outcome, gamedata, channel, bot): if gamedata["ranked"]: winner = db.get_user(winner) loser = db.get_user(loser) guildid = channel.guild.id if (outcome == "resign" and len(gamedata["moves"]) >= 10) or outcome == "checkmate": db.inc_user(winner["id"], "wins", 1) db.inc_user(loser["id"], "loss", 1) db.inc_user(winner["id"], "games", 1) db.inc_user(loser["id"], "games", 1) if loser["id"] not in winner["unique"]: db.push_user(winner["id"], "unique", loser["id"]) db.inc_user(winner["id"], "xp", 150) else: db.inc_user(winner["id"], "xp", 50) new_elo = elo_rating(winner["elo"], loser["elo"], config.ELO_K) db.update_user(winner["id"], "elo", new_elo[0]) db.update_user(loser["id"], "elo", new_elo[1]) if winner["team"] != None and loser["team"] != None and winner[ "team"] != loser["team"]: lteam = db.get_team(loser["team"]) mon = int(lteam["cur"] * 0.05) db.inc_team(winner["team"], "cur", mon) db.inc_team(loser["team"], "cur", -mon) db.inc_team(winner["team"], "games", 1) db.inc_team(loser["team"], "games", 1) db.inc_team(winner["team"], "wins", 1) db.inc_team(loser["team"], "loss", 1) if outcome == "checkmate": await channel.send("<@!" + str(winner["id"]) + "> " + random.choice(config.WINMESSAGES) + " <@!" + str(loser["id"]) + ">! Checkmate!") db.end_game(gamedata["_id"], winner["id"], loser["id"], "checkmate") await bot.get_channel(config.LOGCHANNEL ).send("`Checkmate Game: " + winner["name"] + " " + loser["name"] + " " + str(guildid) + "`") if outcome == "resign": if len(gamedata["moves"]) >= 10: await channel.send("You have resigned! <@!" + str(winner["id"]) + "> wins!") db.end_game(gamedata["_id"], winner["id"], loser["id"], "resign") await bot.get_channel( config.LOGCHANNEL ).send("`Resign Game: " + winner["name"] + " " + loser["name"] + " " + str(guildid) + "`") else: await channel.send("You have resigned!") await bot.get_channel(config.LOGCHANNEL ).send("`Exit Game: " + winner["name"] + " " + loser["name"] + " " + str(guildid) + "`") db.end_game(gamedata["_id"], None, None, "exit") if outcome == "draw" or outcome == "stalemate" or outcome == "accepteddraw": db.inc_user(winner["id"], "games", 1) db.inc_user(loser["id"], "games", 1) db.inc_user(winner["id"], "draws", 1) db.inc_user(loser["id"], "draws", 1) if outcome == "draw": await channel.send("Unable to Checkmate! The game is a draw!") db.end_game(gamedata["_id"], None, None, "draw") if outcome == "accepteddraw": await channel.send("Draw offer accepted! The game is a draw!") db.end_game(gamedata["_id"], None, None, "draw") if outcome == "stalemate": await channel.send("Stalemate! The game is a draw!") db.end_game(gamedata["_id"], None, None, "stalemate") if winner["team"] != None and loser["team"] != None and winner[ "team"] != loser["team"]: db.inc_team(winner["team"], "games", 1) db.inc_team(loser["team"], "games", 1) db.inc_team(winner["team"], "draws", 1) db.inc_team(loser["team"], "draws", 1) if outcome == "exit": await channel.send('You have exited the game!') db.end_game(gamedata["_id"], None, None, "exit") await bot.get_channel(config.LOGCHANNEL ).send("`Exit Game: " + str(guildid) + "`") if winner["wins"] == 2: if not "novice" in winner["badges"]: db.push_user(winner["id"], "badges", "novice") await channel.send( "<@!" + str(winner["id"]) + ">, congratulations! You have earned the Novice badge!") if winner["wins"] == 6: if not "expert" in winner["badges"]: db.push_user(winner["id"], "badges", "expert") await channel.send( "<@!" + str(winner["id"]) + ">, congratulations! You have earned the Expert badge!") if winner["wins"] == 14: if not "pro" in winner["badges"]: db.push_user(winner["id"], "badges", "pro") await channel.send( "<@!" + str(winner["id"]) + ">, congratulations! You have earned the Pro badge!") if winner["games"] == 24: if not "addicted" in winner["badges"]: db.push_user(winner["id"], "badges", "addicted") await channel.send( "<@!" + str(winner["id"]) + ">, congratulations! You have earned the Addicted badge!") if loser["games"] == 24: if not "addicted" in loser["badges"]: db.push_user(loser["id"], "badges", "addicted") await channel.send( "<@!" + str(loser["id"]) + ">, congratulations! You have earned the Addicted badge!") if loser["id"] == 206519445160460288: if not "beat-moca" in winner["badges"] and outcome in [ "resign", "checkmate" ]: db.push_user(winner["id"], "badges", "beat-moca") await channel.send( "<@!" + str(winner["id"]) + ">, congratulations! You have earned the Beat Moca badge!") else: await channel.send( "<@!" + str(loser["id"]) + ">, congratulations! You have earned the Addicted badge!") if outcome == "resign": await channel.send("You have resigned! The computer wins!") db.end_game(gamedata["_id"], "computer", loser, "resign") if outcome == "exit": await channel.send('You have exited the game!') db.end_game(gamedata["_id"], None, None, "exit") if outcome == "checkmate": if winner == "computer": await channel.send(winner + " " + random.choice(config.WINMESSAGES) + " <@!" + loser + ">! Checkmate!") db.end_game(gamedata["_id"], "computer", loser, "checkmate") else: await channel.send("<@!" + winner + "> " + random.choice(config.WINMESSAGES) + " " + loser + " Checkmate!") db.end_game(gamedata["_id"], winner, "computer", "checkmate") if outcome == "draw": await channel.send("Unable to Checkmate! The game is a draw!") db.end_game(gamedata["_id"], None, None, "draw") if outcome == "stalemate": await channel.send("Stalemate! The game is a draw!") db.end_game(gamedata["_id"], None, None, "stalemate")