async def on_rule_accept(player, interaction_id, interaction, interaction_values): user = interaction.user if modules.loader.is_all_locked(): raise modules.interactions.InteractionNotAllowed # reaction to the rule message? p = Player.get(user.id) if not p: # if new player # create a new profile p = Player(user.id, user.name) await modules.roles.role_update(p) await modules.database.async_db_call(modules.database.set_element, "users", p.id, p.get_data()) await disp.REG_RULES.send( ContextWrapper.channel(cfg.channels["register"]), user.mention) elif p.is_away: p.is_away = False await modules.roles.role_update(p) await p.db_update("away") await disp.AWAY_BACK.send( ContextWrapper.channel(cfg.channels["register"]), p.mention) else: i_ctx = InteractionContext(interaction) await disp.REG_RULES_ALREADY.send(i_ctx) await modules.roles.role_update(p)
async def timeout(self, ctx, *args): if len(args) == 1 and args[0] == "help": await disp.RM_TIMEOUT_HELP.send(ctx) return if len(ctx.message.mentions) != 1: await disp.RM_MENTION_ONE.send(ctx) return player = Player.get(ctx.message.mentions[0].id) if not player: # player isn't even registered in the system... player = Player(ctx.message.mentions[0].id, ctx.message.mentions[0].name) await db.async_db_call(db.set_element, "users", player.id, player.get_data()) if player.is_lobbied: lobby.remove_from_lobby(player) await disp.RM_LOBBY.send( ContextWrapper.channel(cfg.channels["lobby"]), player.mention, names_in_lobby=lobby.get_all_names_in_lobby()) if player.match: await disp.RM_IN_MATCH.send(ctx) return if len(args) == 0: if player.is_timeout: await disp.RM_TIMEOUT_INFO.send( ctx, dt.utcfromtimestamp( player.timeout).strftime("%Y-%m-%d %H:%M UTC")) return await roles.role_update(player) await roles.perms_muted(False, player.id) await disp.RM_TIMEOUT_NO.send(ctx) return # =timeout @player remove if len(args) == 1 and args[0] == 'remove': player.timeout = 0 await player.db_update("timeout") await disp.RM_TIMEOUT_FREE.send(ctx, player.mention) await roles.role_update(player) await roles.perms_muted(False, player.id) return # Check if command is correct (=timeout @player 12 d) time = tools.time_calculator(" ".join(args)) if time == 0: await disp.RM_TIMEOUT_INVALID.send(ctx) return end_time = tools.timestamp_now() + time player.timeout = end_time await roles.role_update(player) await player.db_update("timeout") await roles.perms_muted(True, player.id) await disp.RM_TIMEOUT.send( ctx, player.mention, dt.utcfromtimestamp(end_time).strftime("%Y-%m-%d %H:%M UTC"))
def push_accounts_to_users(): accs = get_accounts() loop = asyncio.get_event_loop() p_list = list() for acc in accs: p = Player(int(acc), f"_POG_ACC_{acc}") p_list.append(p) print(acc) char_list = [f"POGx{acc}VS", f"POGx{acc}TR", f"POGx{acc}NC"] p.__has_own_account = True p.__is_registered = True loop.run_until_complete(p._add_characters(char_list)) db.set_element("users", p.id, p.get_data()) loop.close()
async def launch(ctx, id_list, tier): print("TIER 1") players = list() for p_id in id_list: player = Player.get(p_id) if not player: print(f"user {p_id}") user = await bot.fetch_user(p_id) player = Player(user.id, user.name) await db.async_db_call(db.set_element, "users", player.id, player.get_data()) await player.register(None) players.append(player) for p in players: lobby.add_to_lobby(p) if tier == 1: return print("TIER 2") await asyncio.sleep(1) match = players[0].match while match.status is not MatchStatus.IS_CAPTAIN: await asyncio.sleep(1) cap_1_ctx = ContextWrapper.wrap(ctx.channel) cap_1_ctx.message = ctx.message cap_1_ctx.author = ctx.guild.get_member(players[0].id) await match.on_volunteer(players[0]) cap_2_ctx = ContextWrapper.wrap(ctx.channel) cap_2_ctx.message = ctx.message cap_2_ctx.author = ctx.guild.get_member(players[1].id) await match.on_volunteer(players[1]) if tier == 2: return print("TIER 3") while match.status is not MatchStatus.IS_PICKING: await asyncio.sleep(1) picked = ContextWrapper.user(players[2].id) cap_1_ctx.message.mentions.clear() cap_1_ctx.message.mentions.append(picked.author) await match.command.pick(cap_1_ctx, [""]) if tier == 3: return print("TIER 4") while match.status is not MatchStatus.IS_FACTION: await asyncio.sleep(1) cap_2_ctx.message.mentions.clear() cap_1_ctx.message.mentions.clear() await match.command.pick(cap_2_ctx, ["VS"]) await match.command.pick(cap_1_ctx, ["TR"]) if tier == 4: return print("TIER 5") while match.status is not MatchStatus.IS_BASING: await asyncio.sleep(1) # We assume tester is an admin await match.command.base(ctx, ["ceres"]) if tier == 5: return print("TIER 6") while match.status is not MatchStatus.IS_WAITING: await asyncio.sleep(1) match.change_check("online") match.change_check("account") await match.command.ready(cap_1_ctx) await match.command.ready(cap_2_ctx)