Esempio n. 1
0
async def on_message(message: discord.Message):
    if not await check_message(
            client, message
    ):  # check basic conditions like length and not responding to himself
        return

    if message.channel.id in cfg.get("channel_ids",
                                     dict()).get("suggestions", []):
        await message.delete()
        info = InfoEmbed(f"Suggestion by {message.author.display_name}")
        info.description = message.content
        info.set_author(name=message.author.display_name,
                        icon_url=message.author.avatar_url_as(format="webp"))
        info.set_footer(text=f"UserID: {message.author.id}")
        new_message = await message.channel.send(embed=info)
        await new_message.add_reaction('👍')
        await new_message.add_reaction('👎')
        return

    if message.content.lower().startswith(
            str(cfg.options["invoke_normal"]).lower()):
        params = commands.parse(message.content, False)
        if params:
            if params[0].lower() in commands.commands.keys():
                await commands.commands[params[0].lower()](client, message,
                                                           params[1:])

    elif message.content.lower().startswith(
            str(cfg.options["invoke_mod"]).lower()):
        params = commands.parse(message.content, True)
        if params:
            if params[0].lower() in commands.mod_commands.keys():
                await commands.mod_commands[params[0].lower()](client, message,
                                                               params[1:])
Esempio n. 2
0
async def main(client, message, params):
    roles = cfg.options["roles_show"]
    info = InfoEmbed(title="Roles")
    desc = 'This server has ' + str(
        client.get_guild(message.guild.id).member_count) + ' members.\n\n'
    for r in roles:
        role = get(message.guild.roles, name=r)
        desc += role.name + ': ' + str(len(role.members)) + '.\n'
    info.description = desc
    await message.channel.send(embed=info)
Esempio n. 3
0
async def end_discussion(args):
    client = args[0]
    data = handleJson.read_json_raw(path)
    if data["arena_status"] == "running":
        SHL.output("Ended discussion")
        SHL.output("Started poll")
        channel = client.get_channel(cfg.options["channel_ids"]["arena"])
        role = get(channel.guild.roles, id=cfg.options["arena_role"])
        embed = InfoEmbed(title="Arena - End",
                          description="Arena stopped. Thank you for your participation")
        for m in data["participants"]:
            try:
                member = channel.guild.get_member(m)
                await member.remove_roles(role)
                await member.send(embed=embed)
            except:
                pass

        embed = SuccessEmbed(title="Arena - End")
        if len(data["participants"]) == 2:
            embed.description = "Ended discussion.\n Please vote for:\n"\
                                f"1⃣  {data['participants_name'][0]}\n" \
                                f"2⃣  {data['participants_name'][1]}\n"
            emojis = ['1⃣', '2⃣']
        elif len(data["participants"]) == 4:
            embed.description = "Ended discussion.\n Please vote for:\n" \
                                f"1⃣  {data['participants_name'][0]}\n" \
                                f"2⃣  {data['participants_name'][1]}\n" \
                                f"3⃣  {data['participants_name'][2]}\n" \
                                f"4⃣  {data['participants_name'][3]}\n"
            emojis = ['1⃣', '2⃣', '3⃣', '4⃣']
        close = await channel.send(embed=embed)
        data["last_poll_msg"] = close.id
        for e in emojis:
            await close.add_reaction(e)

        data["arena_status"] = "poll"
        handleJson.saveasjson(path, data)
Esempio n. 4
0
def survey_help_embed():
    embed = InfoEmbed(title='Hilfe - BundestagsBot v1')
    embed.set_thumbnail(
        url=
        'https://cdn0.iconfinder.com/data/icons/handdrawn-ui-elements/512/Question_Mark-512.png'
    )

    embed.description = '>survey Titel; Beschreibung; <Anzahl>\n\n'\
                        'Anzahl ist optional und beschreibt die Anzahl an Reactionmöglichkeiten.\n\n'\
                        'So erzeugt >survey; Titel; Beschreibung; 5 eine Umfrage mit 5 Antwortmöglichkeiten, die du\n'\
                        'dann in deiner Beschreibung erklären musst.\n'\
                        'Mit "|" erzeugst du eine neue Zeile in deiner Beschreibung.\n'\
                        '**Beachte bitte die Trennung der Argumente via Semikolon!**'
    return embed
Esempio n. 5
0
async def main(client, message, params):
    error = NoticeEmbed(title="Resolve")
    info = InfoEmbed(title="Resolve")
    if len(str(message.content).split(' ')) == 2:
        submit_id = params[0][1:]
        if submit_id.isdigit():
            data = handleJson.read_json_raw(path)
            if submit_id in data.keys():
                info.description = f"Anfrage #{submit_id} ist von:\n" \
                                   f"{data[submit_id]['author']}\n" \
                                   f"{data[submit_id]['authorID']}"
                await message.channel.send(embed=info)
            else:
                error.description = f"#{submit_id} could not be assigned to a submit."
                await message.channel.send(embed=error)
        else:
            error.description = f"{submit_id} is an invalid ID."
            await message.channel.send(embed=error)
    else:
        error.description = f"Invalid syntax.\nPlease use {cfg.options['invoke_mod']}resolve #id"
        await message.channel.send(embed=error)
Esempio n. 6
0
def help_embed():
    embed = InfoEmbed(title='Hilfe - BundestagsBot v1')
    embed.set_thumbnail(
        url=
        'https://cdn0.iconfinder.com/data/icons/handdrawn-ui-elements/512/Question_Mark-512.png'
    )
    embed.description = '-Benutze >survey Titel; Beschreibung; <Anzahl>\n' \
                        'um eine Umfrage zu erstellen. >help survey für mehr Details\n\n'\
                        '-Benutze >iam [Politik] um dir diese Rolle zuzuweisen.\n\n'\
                        '-Benutze >roles für eine Übersicht der Rollenverteilung.\n\n'\
                        '-Benutze >answer #id answer um auf eine Umfrage zu antworten.\n\n' \
                        '-Benutze >result #id um Ergebnisse einer Umfrage einzusehen.\n\n' \
                        '-Benutze >sub False um keine weiteren Umfragen mehr zu erhalten.\n\n' \
                        '-Benutze >submit Text um Anfragen ans Serverteam zu stellen.\n\n' \
                        '-Benutze >umfrage [Parlamentsnummer]\nKeine Nummer für Bundestag'\

    embed.add_field(
        name='Liste:',
        value=
        '0: Bundestag\n1: Baden-Württemberg\n2: Bayern\n3: Berlin\n4: Brandeburg\n5: Bremen\n'
        '6: Hamburg\n7: Hessen\n8: Mecklenburg-Vorpommern\n9: Niedersachsen\n10: NRW\n'
        '11: Rheinland-Pfalz\n12: Saarland\n13: Sachsen\n14: Sachsen-Anhalt\n'
        '15: Schleswig-Holstein\n16: Thüringen\n17: Europäisches Parlament')
    return embed
Esempio n. 7
0
def create_embed(submit_id, author, params):
    info = InfoEmbed(title=f"Answer Submit #{submit_id}")
    info.description = ' '.join(params[1:]).strip()
    info.set_footer(text=f'Answer by {author}')
    return info
Esempio n. 8
0
SHL = Console("BundestagsBot Analyze"
              )  # Use SHL.output(text) for all console based output!

settings = {
    'name': 'analyze',  # name/invoke of your command
    'mod_cmd':
    False,  # if this cmd is only useable for users with the teamrole
    'channels':
    ['all'],  # allowed channels: [dm, bot, team, all]; use !dm to blacklist dm
    'log': True,  # if this cmd should be logged to the console, default: True
}

about_embed = InfoEmbed(title="Help")
with open(os.path.join("static", "info.txt"), "r", encoding="utf-8") as fh:
    about_embed.description = fh.read()


async def main(client, message, params):
    if any([
            x in message.content.lower()
            for x in ["help", "info", "details", "about"]
    ]):
        await message.channel.send(embed=about_embed)
        return

    if "true" in message.content.lower():
        with open(os.path.join(content_dir, "unsubs.json"), "r") as fh:
            data = json.load(fh)
        try:
            data["unsub_ids"].remove(message.author.id)