Exemplo n.º 1
0
async def cleanerkey(ctx, userid: int):
    if ctx.message.author.id != 266947686194741248:
        await ctx.message.channel.send("no")
        return
    await ctx.trigger_typing()
    me = ctx.message.channel.guild.me
    tosend = client.get_user(userid)

    myemoji = client.get_emoji(787237116630532106)
    chemoji = client.get_emoji(788129603876421632)
    key = uuid.uuid1()
    msg = '┌─────┈{0}┈────┐\n{3}Clearner Key!{4}\n└─────┈{1}┈────┘\n\nCleaner key has been generated!\n\n\nPrivate ' \
          'key: `{2}`\n\nPlease use this key log into the cleaner client!'.format(
        myemoji, myemoji, key, chemoji, chemoji)
    em = discord.Embed(title='', description=msg, colour=0x9b59b6)
    em.set_author(name='', icon_url=ctx.message.author.avatar_url)
    em.set_footer(text="Key generated!", icon_url=me.avatar_url)
    try:
        await tosend.send(embed=em)
    except:
        await ctx.message.channel.send("I could not send the code to " +
                                       tosend.name + tosend.discriminator +
                                       ". Kindly ask them to change their "
                                       "dm settings and try again!")

    con = await dbConnect()
    mycursor = con.cursor()
    mycursor.execute("INSERT INTO clean (mkey, userid) VALUES ('" + str(key) +
                     "', '" + str(tosend.id) + "')")
    con.commit()
    con.close()
    await ctx.message.channel.send("Keys has successfully been sent!")
Exemplo n.º 2
0
async def sendHelpMessage(channel):

    message = "Here is the list of commands!\nFor more info on a command, use `{command}` to view usage help.\nFor further assistance join our [guild](https://discord.gg/79kbdEDwnV)\n\n"
    em = discord.Embed(title='', description=message, colour=0xe67e22)
    em.set_author(name="Command help", icon_url=channel.guild.icon_url)

    emoji = client.get_emoji(788351325531537428)
    em.add_field(name=f"{emoji} Emoji",
                 value="`addemoji` `delemoji`",
                 inline=False)

    emoji = client.get_emoji(777915907644850227)
    em.add_field(name=f"{emoji} Roster",
                 value="`roster` `droster` `rosters`",
                 inline=False)

    emoji = client.get_emoji(817499208189345882)
    em.add_field(
        name=f"{emoji} Tournament",
        value=
        "`create_tourney` `cancel_tourney` `tourney_role` `close_tourney` `sendkeys`",
        inline=False)

    emoji = client.get_emoji(565838171363868682)
    em.add_field(name=f"{emoji} Special Mute",
                 value="`mute` `unmute`",
                 inline=False)

    emoji = client.get_emoji(817523844004053044)
    em.add_field(name=f"{emoji} Minecraft", value="`server`", inline=False)

    em.set_footer(text="You must use `i` prefix before the commands!",
                  icon_url=client.user.avatar_url)
    await channel.send(embed=em)
Exemplo n.º 3
0
async def handleReaction(message):

    for x in emoji_list:
        if message.channel.guild.id == x.server and message.author.id == x.user:
            cur_time = int(time.time())
            last_reaction_time = await getReactionTime(message.author.id)
            if (cur_time - last_reaction_time) > 2 and not await isMuted(
                    message.author.id, message.channel.guild.id):
                try:
                    emoji = client.get_emoji(x.emoji)
                    await message.add_reaction(emoji)
                    setReactionTime(message.author.id, cur_time)
                except discord.errors.HTTPException:
                    await delete_emoji(emoji.id, x.user,
                                       message.channel.guild.id)
Exemplo n.º 4
0
async def create_tourney(ctx, *, name=None):

    if name is None:
        await ctx.message.channel.send("**Usage:** icreate_tourney `<name>`")
        return

    try:
        perms = ctx.message.author.guild_permissions
        if not perms.administrator:
            await sendError("You must be a server admin in order to create a tournament!",  "", ctx)
            return

        myperms = ctx.message.channel.guild.me.guild_permissions
        if not myperms.manage_channels:
            await sendError("I need manage channel permission in order to do this!", "", ctx)
            return

        name = name.replace("<", "").replace(">", "")

        con = await dbConnect()
        mycursor = con.cursor()
        mycursor.execute(f"SELECT * FROM tournaments WHERE userid = {ctx.message.author.id} AND status = 1")
        result = mycursor.fetchone()
        if result is not None:
            await ctx.message.channel.send(
                "**[ERROR]** You already have an ongoing tournament! cancel it first using `icancel_tourney`!")
            return

        await ctx.trigger_typing()

        category = await ctx.message.channel.guild.me.guild.create_category(name)
        overwrites = {
            ctx.message.channel.guild.me.guild.default_role: discord.PermissionOverwrite(read_messages=False),
            ctx.message.channel.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True),
            ctx.message.author: discord.PermissionOverwrite(read_messages=True, send_messages=True)
        }
        logs = await ctx.message.channel.guild.me.guild.create_text_channel("┌📈𝗟𝗢𝗚𝗦", overwrites=overwrites, category=category)
        alerts = await ctx.message.channel.guild.me.guild.create_text_channel("└👥𝗔𝗟𝗘𝗥𝗧𝗦", overwrites=overwrites, category=category)

        av_commands = "Here's the list of available commands that can be used in {0} or {1} by organizers!\n`closeconnection name` - Close the connection for a" \
                      "user.\n**Example:** `closeconnection iLearner`\n\n`processlist name` - Get the current list of running processes from task manager for a " \
                      "user.\n**Example:**`processlist iLearner`\n\nHope you enjoy your time!".format(logs.mention,
                                                                                                      alerts.mention)
        em = discord.Embed(title='Available commands', description=av_commands, colour=0x2ecc71)
        em.set_author(name='', icon_url=ctx.message.author.avatar_url)
        em.set_footer(text=name, icon_url=ctx.message.channel.guild.me.avatar_url)
        await logs.send(embed=em)
        await alerts.send(embed=em)

        myemoji = client.get_emoji(787237116630532106)
        chemoji = client.get_emoji(788129603876421632)
        msg = '┌─────┈{0}┈────┐\n{6}Tournament created!{7}\n└─────┈{1}┈────┘\n\nTournament has been created!\n\nTournament name: {2}\nTournament organizer: {3}\nLogs channel: {4}\nAlerts channel: {5}\n\nPlease add members to your tournament with the command `itourney_role @role`\n\nSend private keys to all members before the tournament with the command `isendkeys`'.format(
            myemoji, myemoji, name, ctx.message.author.mention, logs.mention, alerts.mention, chemoji, chemoji)
        em = discord.Embed(title='', description=msg, colour=0x9b59b6)
        em.set_author(name='', icon_url=ctx.message.author.avatar_url)
        em.set_footer(text="Tournament created!", icon_url=ctx.message.channel.guild.me.avatar_url)
        await ctx.message.channel.send(embed=em)

        query = f"INSERT INTO tournaments (name, userid, serverid, logchannel, alertchannel) VALUES ('{escape_string(name)}', '{ctx.message.author.id}', '{ctx.message.channel.guild.me.guild.id}', '{logs.id}', '{alerts.id}')"
        mycursor.execute(query)
        con.commit()
        con.close()
    except Exception as e:
        await sendError(f"Something went wrong... contant admin!\nPlease report the following error log:`\n{str(e)}", "", ctx)
Exemplo n.º 5
0
async def roster(ctx, channel: discord.TextChannel, role: discord.Role):
    perms = ctx.message.author.guild_permissions
    tick_emoji = client.get_emoji(806114376297611266)
    redtick_emoji = client.get_emoji(806117763784638464)
    await ctx.trigger_typing()
    if not perms.administrator:
        await ctx.message.channel.send(
            "**[ERROR]** You must be a server admin in order to create a roster"
        )
        return
    await sendEmbed(
        "Welcome to iBot's Clan Roster Setup\n\nPlease type the header of the roster (top text)\n**Example** My Clan Members",
        "Note: Only use default font, support for different fonts will be added!",
        ctx)

    def check(m):
        return m.author == ctx.message.author and m.channel == ctx.message.channel

    try:
        msg = await client.wait_for('message', check=check)
    except:
        await sendError("Setup timed out! Please start over.", "", ctx)

    if len(msg.content) > 100:
        await sendError("The header must be less than 100 characters!", "",
                        ctx)
        return
    await msg.add_reaction(tick_emoji)

    clan_emoji = client.get_emoji(812578319308161045)
    await sendEmbed(
        "Please type the clan symbol/emoji: \n**Example** ♅ or {0}".format(
            clan_emoji), "", ctx)
    try:
        symbol = await client.wait_for('message', timeout=60.0, check=check)
    except:
        await sendError("Setup timed out! Please start over.", "", ctx)

    if len(symbol.content) > 200:
        await sendError("The symbol must be less than 200 characters!", "",
                        ctx)
        return
    await symbol.add_reaction(tick_emoji)

    await sendEmbed("Please type the roster colour RGB:\n**Example** #FF0000",
                    "", ctx)
    try:
        color = await client.wait_for('message', timeout=60.0, check=check)
    except:
        await sendError("Setup timed out! Please start over.", "", ctx)

    await color.add_reaction(tick_emoji)
    try:
        readableHex = await ColourConverter().convert(ctx, color.content)
    except:
        await sendError(
            "Invalid colour code!\nAborting setup.\n\nMake sure it's a valid colour code! Get one from [here](https://www.color-hex.com/)",
            "", ctx)
        return

    await ctx.message.channel.send("Example of how it will look like:")
    example_msg = '**{0}**\n\n{1} **{2}**'.format(msg.content, symbol.content,
                                                  "iLearner")
    em = discord.Embed(title='', description=example_msg, colour=readableHex)
    await ctx.message.channel.send(embed=em)
    msg_confirm = await ctx.message.channel.send(
        "React with {0} to confirm!".format(tick_emoji))
    await msg_confirm.add_reaction(tick_emoji)
    await msg_confirm.add_reaction(redtick_emoji)

    def check(reac, reacuser):
        return reacuser == ctx.message.author

    try:
        reaction, user = await client.wait_for('reaction_add',
                                               timeout=60.0,
                                               check=check)
    except:
        await sendError("Setup timed out! Please start over.", "", ctx)

    if reaction.emoji == tick_emoji:
        example_msg = "**{0}**\n\n".format(msg.content)
        for member in ctx.message.channel.guild.members:
            for mrole in member.roles:
                if mrole.id == role.id:
                    if member.nick is not None:
                        example_msg += '{0} **{1}**\n'.format(
                            symbol.content, member.nick)
                    else:
                        example_msg += '{0} **{1}**\n'.format(
                            symbol.content, member.name)

        example_msg += "\n\n"
        if len(example_msg) > 6000:
            await sendError("Members list too long!\n\nSetup aborted!", "",
                            ctx)
            return

        if len(example_msg) > 2000:

            piece = example_msg[1900:2000]
            em = discord.Embed(title='',
                               description=example_msg[:1900 +
                                                       piece.index("\n")],
                               colour=readableHex)
            msg_id = await channel.send(embed=em)

            st_index = 1900 + piece.index("\n")
            piece = example_msg[3900:4000]
            en_index = 3900 + piece.index("\n")
            em = discord.Embed(title='',
                               description=example_msg[st_index:en_index],
                               colour=readableHex)
            msg_id1 = await channel.send(embed=em)

            if len(example_msg) > 4000:

                piece = example_msg[(len(example_msg) - 100):len(example_msg)]
                st_index = en_index
                en_index = (len(example_msg) - 100) + piece.index("\n")
                em = discord.Embed(title='',
                                   description=example_msg[st_index:en_index],
                                   colour=readableHex)
                msg_id2 = await channel.send(embed=em)

                added = await add_roster(
                    ctx.message.channel.guild.id, channel.id, role.id,
                    str(msg_id.id) + "," + str(msg_id1.id) + "," +
                    str(msg_id2.id), msg.content, symbol.content,
                    color.content)
            else:
                added = await add_roster(
                    ctx.message.channel.guild.id, channel.id, role.id,
                    str(msg_id.id) + "," + str(msg_id1.id), msg.content,
                    symbol.content, color.content)

        else:
            em = discord.Embed(title='',
                               description=example_msg,
                               colour=readableHex)
            msg_id = await channel.send(embed=em)
            added = await add_roster(ctx.message.channel.guild.id, channel.id,
                                     role.id, str(msg_id.id), msg.content,
                                     symbol.content, color.content)
        if added:
            await sendEmbed(
                "Setup complete!\nUse `irosters` to see the list of rosters",
                "", ctx)
        else:
            await sendError("Something went wrong...", "", ctx)
            await msg_id.delete()
    else:
        await ctx.message.channel.send("Setup aborted!")
Exemplo n.º 6
0
async def sendkeys(ctx):
    me = ctx.message.channel.guild.me
    await ctx.trigger_typing()
    con = await dbConnect()
    mycursor = con.cursor()
    mycursor.execute("SELECT * FROM tournaments WHERE userid = " +
                     str(ctx.message.author.id) + " and status = 1")
    result = mycursor.fetchone()
    if result is None:
        await ctx.message.channel.send(
            "**[ERROR]** You don't have a tourney! Create one with `?create_tourney`!"
        )
        return

    if result[7] is None:
        await ctx.message.channel.send(
            "**[ERROR]** You must link a role to the tourney first! Link one with `?tourney_role`!"
        )
        return

    progress = await ctx.message.channel.send("Sending keys...")

    mycursor.execute(
        F'SELECT * FROM tournaments WHERE userid = {ctx.message.author.id} AND status = 1 LIMIT 1'
    )
    tournament_info = mycursor.fetchone()

    mycursor.execute(
        F'SELECT * FROM players WHERE tID = {tournament_info[0]} and codeStatus = 1'
    )
    player_info = mycursor.fetchall()

    count = 0
    for member in me.guild.members:
        for role in member.roles:
            if role.id == int(tournament_info[7]):

                mycursor.execute("SELECT * FROM players WHERE userid = '" +
                                 str(member.id) + "' AND tID = " +
                                 str(tournament_info[0]) + " LIMIT 1")
                u_info = mycursor.fetchone()
                if u_info is None:
                    mycursor.execute(
                        "INSERT INTO players (tID, userid) VALUES ('" +
                        str(tournament_info[0]) + "', '" + str(member.id) +
                        "')")
                    con.commit()

                if not codeSent(player_info, member.id):

                    myemoji = client.get_emoji(787237116630532106)
                    chemoji = client.get_emoji(788129603876421632)
                    userobj = client.get_user(int(tournament_info[2]))
                    key = uuid.uuid1()
                    msg = '┌─────┈{0}┈────┐\n{5}Tournament Keys!{6}\n└─────┈{1}┈────┘\n\nTournament key has been generated!\n\nTournament name: {2}\nTournament organizer: {3}\nPrivate key: `{4}`\n\nPlease use this key log into the anticheat client!'.format(
                        myemoji, myemoji, tournament_info[1], userobj.name,
                        key, chemoji, chemoji)
                    em = discord.Embed(title='',
                                       description=msg,
                                       colour=0x9b59b6)
                    em.set_author(name='',
                                  icon_url=ctx.message.author.avatar_url)
                    em.set_footer(text="Key generated!",
                                  icon_url=me.avatar_url)
                    try:
                        await member.send(embed=em)
                        await member.send(
                            "Join the support server to download the client: https://discord.gg/79kbdEDwnV"
                        )
                        mycursor.execute("UPDATE players SET code = '" +
                                         str(key) +
                                         "', codeStatus = 1 WHERE userid = '" +
                                         str(member.id) + "' AND tID = '" +
                                         str(tournament_info[0]) + "'")
                        con.commit()
                        count += 1
                        await progress.edit(
                            content=
                            f"Sent keys to: {member.name} | Total keys send: {count}"
                        )
                    except:
                        await ctx.message.channel.send(
                            f"I could not send the code to {member.name} {member.discriminator}. Kindly ask them to change their dm settings and use `isendkeys` again!"
                        )

    await progress.edit(
        content=f"Keys have successfully been sent to {count} user(s)!")
    con.close()