async def blockparty(cmd):
    if not cmd.message.author.guild_permissions.administrator:
        return
    else:
        blockstate = EwGamestate(id_server=cmd.guild.id, id_state='blockparty')
        if cmd.tokens_count > 1:
                if cmd.tokens[1] == 'slimegen':
                    blockstate.bit = 1
                    blockstate.persist()
                    response = "Slimegen turned on."
                elif cmd.tokens[1] == 'close':
                    blockstate.bit = 0
                    blockstate.value = ''
                    blockstate.persist()
                    response = "OK, closing up."
                else:
                    poi_sought = ewutils.flattenTokenListToString(cmd.tokens[1:])
                    poi = poi_static.id_to_poi.get(poi_sought)
                    if poi is not None:
                        time_end = int(time()) + (60 * 60 * 6) # 6 hours
                        blockstate.value = "{}{}".format(poi.id_poi, time_end)
                        blockstate.persist()
                        response = "Block party in {}! Everybody in!".format(poi.str_name)
                    else:
                        response = "Never heard of it."
        else:
            response = "I see you haven't gotten any smarter. Try !blockparty <setting>. Settings include 'close', 'slimegen', and any POI."
    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#2
0
async def update_slimernalia_kingpin(client, server):
    return
    # Depose current slimernalia kingpin
    kingpin_state = EwGamestate(id_server=server.id,
                                id_state='slimernaliakingpin')
    old_kingpin_id = int(kingpin_state.value)

    if old_kingpin_id != None and old_kingpin_id > 0:
        kingpin_state.value = '-1'
        try:
            old_kingpin_member = server.get_member(old_kingpin_id)
            await ewrolemgr.updateRoles(client=client,
                                        member=old_kingpin_member)
        except:
            ewutils.logMsg(
                "Error removing kingpin of slimernalia role from {} in server {}."
                .format(old_kingpin_id, server.id))

    # Update the new kingpin of slimernalia

    new_kingpin_id = ewutils.get_most_festive(server)
    kingpin_state.value = str(new_kingpin_id)

    # Reset the new kingpin's festivity upon getting the award
    old_festivity = ewstats.get_stat(id_server=server.id,
                                     id_user=new_kingpin_id,
                                     metric=ewcfg.stat_festivity)
    ewstats.set_stat(id_server=server.id,
                     id_user=new_kingpin_id,
                     metric=ewcfg.stat_festivity,
                     value=0)
    #new_kingpin.festivity = 0
    #new_kingpin.persist()

    try:
        new_kingpin_member = server.get_member(new_kingpin_id)
        await ewrolemgr.updateRoles(client=client, member=new_kingpin_member)
    except:
        ewutils.logMsg(
            "Error adding kingpin of slimernalia role to user {} in server {}."
            .format(new_kingpin_id, server.id))

    if new_kingpin_member:
        # Format and release a message from Phoebus about how who just won and how much slime they got
        announce_content = ewcfg.slimernalia_kingpin_announcement.format(
            player=("@" + str(new_kingpin_member.id)), festivity=old_festivity)

        announce = discord.Embed()
        announce.set_thumbnail(url="https://i.imgur.com/aVfaB9I.png")
        announce.description = "**Phoebus**{}".format(ewcfg.emote_verified)
        announce.color = discord.Color.green()
        announce.add_field(name='\u200b', value=announce_content)

        channel = get_channel(server=server, channel_name="auditorium")

        await send_message(client, channel, embed=announce)
示例#3
0
def canCreateRelic(item, id_server, createstate=0):
    state = EwGamestate(id_server=id_server, id_state=item)

    if state.bit is not None:
        return None
    else:
        state.bit = 0
        state.value = ""
        if createstate == 1:
            state.persist()
        return 1