izhangzhihao / intellij-rainbow-brackets

🌈Rainbow Brackets for IntelliJ based IDEs/Android Studio/HUAWEI DevEco Studio/Fleet
https://plugins.jetbrains.com/plugin/10080-rainbow-brackets
GNU General Public License v3.0
4.44k stars 213 forks source link

[Auto Generated Report]java.lang.Throwable: await ctx.send("|| + mot + "|| #1090

Closed intellij-rainbow-brackets closed 3 years ago

intellij-rainbow-brackets commented 3 years ago
java.lang.Throwable: await ctx.send("|| + mot + "|| :
 parent=mot = " ".join(text)
    messages = await ctx.channel.history(limit=1).flatten()
    for message in messages:
        await message.delete()
    await ctx.send("|| + mot + "|| :\n" + crypting(mot))

@bot.command()  # send a random integer between two numbers, or 1 and 0
async def randint(ctx, *text):
    tab = []
    MESSAGE = "".join(text)
    nb2 = 0
    i = 0
    while i < len(MESSAGE) and MESSAGE[i] != ",":
        if 48 <= ord(MESSAGE[i]) <= 57:
            tab.append(MESSAGE[i])
        i += 1

    if len(tab) == 0:
        await ctx.send("Rentre un nombre banane")
        return

    nb1 = strToInt(tab)

    if i != len(MESSAGE):
        nb2 = strToInt(list=nbInStr(MESSAGE, i, len(MESSAGE)))

    if nb1 == nb2:
        text = "Bah " + str(nb1) + " du coup... 🙄"
        await ctx.send(text)
        return
    if nb2 < nb1:
        temp = nb2
        nb2 = nb1
        nb1 = temp

    rd = random.randint(nb1, nb2)
    print("random ", nb1, ":", nb2, " = ", rd, sep="")
    await ctx.send(rd)

@bot.command()  # same, with a capital letter
async def randInt(ctx, *text):
    await randint(ctx, *text)

@bot.command()  # send a random word from the dico, the first to write it wins
async def game(ctx):
    dicoFile = open("txt/dico.txt", "r+")
    dicoLines = dicoFile.readlines()
    dicoFile.close()

    mot = random.choice(dicoLines)
    mot = mot.replace("\n", "")
    text = f"Le premier à écrire **{mot}** a gagné"
    reponse = await ctx.send(text)

    if ctx.author == bot.user:
        return

    def check(m):
        return m.content == mot and m.channel == ctx.channel

    try:
        msg = await bot.wait_for("message", timeout=60.0, check=check)
    except asyncio.TimeoutError:
        await reponse.add_reaction("☹")
    else:
        user = str(msg.author)
        user = user.replace(user[len(user) - 5:len(user)], "")
        text = f"**{user}** a gagné !"
        await ctx.send(text)

@bot.command()  # do a simple calcul of 2 numbers and 1 operator (or a fractionnal)
async def calcul(ctx, *text):
    tab = []
    symbols = ["-", "+", "/", "*", "^", "!"]
    Message = "".join(text)
    Message = Message.lower()
    nb2 = i = rd = 0

    if "infinity" in Message:
        text = ""
        for i in range(1999):
            text += "9"
        await ctx.send(text)
        return

    while i < len(Message) and 48 <= ord(Message[i]) <= 57:
        if 48 <= ord(Message[i]) <= 57:
            tab.append(Message[i])
        i += 1

    if len(tab) == 0:
        await ctx.send("Rentre un nombre banane")
        return

    if i == len(Message) or Message[i] not in symbols:
        await ctx.send("Rentre un symbole (+, -, *, /, ^, !)")
        return

    symb = Message[i]

    nb1 = strToInt(tab)

    if symb == "!":
        if nb1 > 806:  # can't go above 806 recursion deepth
            await ctx.send("806! maximum, désolé 🤷‍♂️")
            return
        rd = facto(nb1)
        text = str(nb1) + "!=" + str(rd)
        await ctx.send(text)
        return

    if i != len(Message):
        tab = nbInStr(Message, i, len(Message))

        if len(tab) == 0:
            await ctx.send("Rentre un deuxième nombre patate")
            return

        nb2 = strToInt(tab)

    if symb == "+":
        rd = nb1 + nb2
    elif symb == "-":
        rd = nb1 - nb2
    elif symb == "*":
        rd = nb1 * nb2
    elif symb == "/":
        if nb2 == 0:
            await ctx.send("±∞")
            return
        rd = float(nb1 / nb2)
    elif symb == "^":
        rd = nb1 ** nb2
    text = str(nb1) + str(symb) + str(nb2) + "=" + str(rd)
    print(text, rd)
    await ctx.send(text)

@bot.command()  # create a reaction poll with a question, and max 10 propositions
async def poll(ctx, *text):
    tab = []
    Message = " ".join(text)
    text = ""
    for i in range(len(Message)):
        if Message[i] == ",":
            tab.append(text)
            text = ""
        elif i == len(Message) - 1:
            text += Message[i]
            tab.append(text)
        else:
            text += Message[i]
    if len(tab) <= 1:
        await ctx.send(
            "Ecris plusieurs choix séparés par des virgules, c'est pas si compliqué que ça..."
        )
        return
    if len(tab) > 11:
        await ctx.send("Ca commence à faire beaucoup non ?... 10 max ca suffit"
                       )
        return
    text = ""
    for i in range(len(tab)):
        if i == 0:
            text += "❓"
        elif i == 1:
            text += "\n1️⃣"
        elif i == 2:
            text += "\n2️⃣"
        elif i == 3:
            text += "\n3️⃣"
        elif i == 4:
            text += "\n4️⃣"
        elif i == 5:
            text += "\n5️⃣"
        elif i == 6:
            text += "\n6️⃣"
        elif i == 7:
            text += "\n7️⃣"
        elif i == 8:
            text += "\n8️⃣"
        elif i == 9:
            text += "\n9️⃣"
        elif i == 10:
            text += "\n🔟"
        text += tab[i]

    reponse = await ctx.send(text)
    for i in range(len(tab)):
        if i == 1:
            await reponse.add_reaction("1️⃣")
        elif i == 2:
            await reponse.add_reaction("2️⃣")
        elif i == 3:
            await reponse.add_reaction("3️⃣")
        elif i == 4:
            await reponse.add_reaction("4️⃣")
        elif i == 5:
            await reponse.add_reaction("5️⃣")
        elif i == 6:
            await reponse.add_reaction("6️⃣")
        elif i == 7:
            await reponse.add_reaction("7️⃣")
        elif i == 8:
            await reponse.add_reaction("8️⃣")
        elif i == 9:
            await reponse.add_reaction("9️⃣")
        elif i == 10:
            await reponse.add_reaction("🔟")

@bot.command()  # find and send all the prime numbers until 14064991, can calcul above but can't send it (8Mb limit)
async def prime(ctx, nb: int):
    if nb < 2:
        await ctx.send("Tu sais ce que ca veut dire 'prime number' ?")
        return
    Fprime = open("txt/primes.txt", "r+")
    primes = Fprime.readlines()
    Fprime.close()
    biggest = int(primes[len(primes) - 1].replace("\n", ""))
    text = ""
    ratio_max = 1.02
    n_max = int(biggest * ratio_max)
    print(biggest, n_max)

    if nb > biggest:
        if biggest % 2 == 0:
            biggest -= 1
        if nb <= n_max:
            await ctx.send("Donne moi quelques minutes bro...")
            for i in range(biggest, nb + 1, 2):
                if is_prime(i):
                    text += str(i) + "\n"
            Fprime = open("txt/primes.txt", "a+")
            Fprime.write(text)
            Fprime.close()
            if nb > 14064991:  # 8Mb file limit
                text = f"Je peux pas en envoyer plus que 14064991, mais tkt je l'ai calculé chez moi là"
                await ctx.send(text)
        else:
            text = f"Ca va me prendre trop de temps, on y va petit à petit, ok ? (max : {int(n_max)})"
            await ctx.send(text)
    else:
        text = f"Tous les nombres premiers jusqu'a 14064991 (plus grand : {biggest})"
        await ctx.send(text, file=discord.File("txt/prime.txt"))

@bot.command()  # find if 'nb' is a prime number, reacts to the message
async def isPrime(ctx, nb: int):
    if is_prime(nb):
        await ctx.message.add_reaction("👍")
    else:
        await ctx.message.add_reaction("👎")

@bot.command()  # send 'nb' random words of the dico, can repeat itself
async def randomWord(ctx, nb: int):
    dicoFile = open("txt/dico.txt", "r+")
    dicoLines = dicoFile.readlines()
    dicoFile.close()

    text = ""
    for i in range(nb):
        text += random.choice(dicoLines)
        if i != nb - 1:
            text += " "
    text += "."
    text = text.replace("\n", "")
    text = text.replace(text[0], text[0].upper(), 1)
    await ctx.send(text)

@bot.command()  # join the vocal channel fo the caller
async def join(ctx):
    channel = ctx.author.voice.channel
    await channel.connect()

@bot.command()  # leaves it
async def leave(ctx):
    await ctx.voice_client.disconnect()

musics = {}
ytdl = youtube_dl.YoutubeDL()

# class of youtube videos (from youtube_dl)
class Video:
    def __init__(self, link):
        video = ytdl.extract_info(link, download=False)
        video_format = video["formats"][0]
        self.url = video["webpage_url"]
        self.stream_url = video_format["url"]

# plays a song in the vocal channel [TO FIX]
def playSong(clt, queue, song):
    source = discord.PCMVolumeTransformer(
        discord.FFmpegPCMAudio(
            song.stream_url,
            before_options="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
        ))

    def next(_):
        if len(queue) > 0:
            newSong = queue[0]
            del queue[0]
            playSong(clt, queue, newSong)
        else:
            asyncio.run_coroutine_threadsafe(clt.disconnect(), bot.loop)

    clt.play(source, after=next)

@bot.command()  # play theyoutube song attached to the URL (TO FIX)
async def play(ctx, url):
    clt = ctx.guild.voice_client

    if clt and clt.channel:
        video = Video(url)
        musics[ctx.guild].append(video)
    else:
        video = Video(url)
        musics[ctx.guild] = []
        playSong(clt, musics[ctx.guild], video)

@bot.command()
async def translate(ctx, *text):
    translator = Translator()
    text = " ".join(text).lower()
    text = text.split(",")
    if text[0] == "showall":
        text[0] = googletrans.LANGUAGES
        await ctx.send(text[0])
        return
    toTranslate = text[0]
    fromLang = text[1].replace(" ", "")
    toLang = text[2].replace(" ", "")
    try:
        textTranslated = translator.translate(toTranslate,
                                              src=fromLang,
                                              dest=toLang)
        text = (toTranslate + " (" + textTranslated.src + ") -> " +
                textTranslated.text + " (" + textTranslated.dest + ")")
    except:
        text = "Nope, sorry !"
    await ctx.send(text)

@bot.command()
async def master(ctx, *text):
    text = " ".join(text)
    if not len(text) or text.count(",") != 2:
        text = ["add 3", "f*cking terms", "splited by ,"]
    else:
        text = text.split(",")
        for term in text:
            if len(term) not in range(1, 20):
                text = ["add terms", "between", "1 and 20 chars"]
    img = Image.open("images/master.jpg")

    fonts = [
        ImageFont.truetype("fonts/Impact.ttf", 26),
        ImageFont.truetype("fonts/Impact.ttf", 18),
        ImageFont.truetype("fonts/Impact.ttf", 22),
    ]

    sizes = []

    for i in range(len(fonts)):
        sizes.append(fonts[i].getsize(text[i])[0])

    draw = ImageDraw.Draw(img)

    draw.text(
        xy=(170 - (sizes[0]) / 2, 100),
        text=text[0],
        fill=(255, 255, 255),
        font=fonts[0],
    )
    draw.text(
        xy=(250 - (sizes[1]) / 2, 190),
        text=text[1],
        fill=(255, 255, 255),
        font=fonts[1],
    )
    draw.text(
        xy=(330 - (sizes[2]) / 2, 280),
        text=text[2],
        fill=(255, 255, 255),
        font=fonts[2],
    )

    img.save("images/mastermeme.jpg")
    await ctx.send(file=discord.File("images/mastermeme.jpg"))

@bot.command()
async def presentation(ctx, *base):
    base = " ".join(base)
    if not len(base):
        base = "add something dude"
    elif len(base) > 200:
        base = "less text bro, i'm not Word"

    text = [""]
    count = j = 0
    for i in range(len(base)):
        if (j > 20 and base[i] == " ") or j > 30:
            text.append(base[i])
            count += 1
            j = 0
        else:
            j += 1

        text[count] += base[i]
    img = Image.open("images/presentation.png")

    font = ImageFont.truetype("fonts/Impact.ttf", 28)
    count += 1
    draw = ImageDraw.Draw(img)
    for i in range(len(text)):
        size = font.getsize(text[i])
        draw.text(
            xy=(335 - size[0] / 2, 170 + i * size[1] - 10 * count),
            text=text[i],
            fill=(0, 0, 0),
            font=font,
        )

    img.save("images/presentationmeme.png")
    await ctx.send(file=discord.File("images/presentationmeme.png"))

@bot.command()
async def ban(ctx):
    if not ctx.author.guild_permissions.administrator:
        await ctx.send("T'es pas admin, nananananère 😜")
        return
    bansFile = open("txt/bans.txt", "r+")
    bansLines = bansFile.readlines()
    bansFile.close()
    chanID = str(ctx.channel.id) + "\n"
    if chanID in bansLines:
        await ctx.send("Jsuis déjà ban, du calme...")
    else:
        bansFile = open("txt/bans.txt", "a+")
        bansFile.write(chanID)
        bansFile.close()
        await ctx.send("D'accord, j'arrete de vous embeter ici... mais les commandes sont toujours dispos")

@bot.command()
async def unban(ctx):
    if not ctx.author.guild_permissions.administrator:
        await ctx.send("T'es pas admin, nananananère 😜")
        return
    bansFile = open("txt/bans.txt", "r+")
    bansLines = bansFile.readlines()
    bansFile.close()
    chanID = str(ctx.channel.id) + "\n"
    if chanID not in bansLines:
        await ctx.send("D'accord, mais j'suis pas ban, hehe.")
    else:
        bansFile = open("txt/bans.txt", "w+")
        bansFile.write("")
        bansFile.close()
        bansFile = open("txt/bans.txt", "a+")
        for id in bansLines:
            if id == chanID:
                bansLines.remove(id)
                await ctx.send("JE SUIS LIIIIIIBRE")
            else:
                bansFile.write(id)
        bansFile.close()

@bot.command()
async def invite(ctx):
    await ctx.send(
        "Invitez-moi 🥵 !\nhttps://discordapp.com/oauth2/authorize?&client_id=653563141002756106&scope=bot&permissions=8")

"""
@bot.command()
async def say(ctx, number, *text):
    for i in range(int(number)):
        await ctx.send(" ".join(text))
"""

# runs the bot (if you have a TOKEN hahaha)

@bot.command()  # PERSONAL USE ONLY
async def AmongUs(ctx):
    if not ctx.author.guild_permissions.administrator:
        await ctx.send("Nope, t'es pas admin désolé...")
        return

    """
    f_name = open("txt/names.txt", "r+")
    all_names = f_name.readlines()
    random.shuffle(all_names)
    f_name.close()
    random.shuffle(all_names)
    """

    tour = 0
    while 1:
        tour += 1
        test = await ctx.send("On joue ? Réagis pour jouer, sinon tant pis")
        yes = "✅"

        await test.add_reaction(yes)

        time.sleep(10)

        test = await test.channel.fetch_message(test.id)
        users = set()
        for reaction in test.reactions:

            if str(reaction.emoji) == yes:
                async for user in reaction.users():
                    print(reaction)
                    users.add(user)
        """for user in users:
            text = "<@!" + str(user.id) + ">"
            await ctx.send(text)"""

        ids = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
               "20", "21", ]
        for user in users:
            if user.id != 653563141002756106:
                ids.append(user.id)
        random.shuffle(ids)
        if len(ids) < 5:
            await ctx.send("En dessous de 5 joueurs on va avoir du mal...")
        else:
            playersID = equal_games(ids)
            color = [
                0x0000ff,
                0x740001,
                0x458b74,
                0x18eeff,
                0xeae4d3,
                0xff8100,
                0x9098ff,
                0xff90fa,
                0xff1443,
                0xff1414,
                0x7fffd4,
                0x05ff3c,
                0x05ffa1
            ]
            text = "**Partie n°" + str(tour) + "**"
            await ctx.send(text)
            for i in range(len(playersID)):
                y = 0
                embed = discord.Embed(title=("**Equipe n°" + str(i + 1) + "**"), color=random.choice(color))
                embed.set_thumbnail(url="https://tse1.mm.bing.net/th?id=OIP.3WhrRCJd4_GTM2VaWSC4SAAAAA&pid=Api")
                for user in playersID[i]:
                    y += 1
                    embed.add_field(name=("Joueur " + str(y)), value="<@!" + str(user) + ">", inline=True)
                await ctx.send(embed=embed)

        def check(m):
            id_list = [321216514986606592, 359743894042443776, 135784465065574401, 349548485797871617]
            return (m.content == "NEXT" or m.content == "END") and m.channel == ctx.channel and m.author.id in id_list

        msg = await bot.wait_for('message', check=check)
        if msg.content == "END":
            await ctx.send("**Fin de la partie...**")
            break

bot.run(TOKEN)

    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:159)
    at com.intellij.psi.impl.PsiElementBase.notNullChild(PsiElementBase.java:284)
    at com.intellij.psi.impl.PsiElementBase.findNotNullChildByClass(PsiElementBase.java:307)
    at com.jetbrains.python.PyTypeDeclarationStatementImpl.getTarget(PyTypeDeclarationStatementImpl.java:38)
    at com.jetbrains.python.validation.TypeAnnotationTargetAnnotator.visitPyTypeDeclarationStatement(TypeAnnotationTargetAnnotator.java:45)
    at com.jetbrains.python.PyTypeDeclarationStatementImpl.acceptPyVisitor(PyTypeDeclarationStatementImpl.java:55)
    at com.jetbrains.python.psi.impl.PyBaseElementImpl.accept(PyBaseElementImpl.java:69)
    at com.jetbrains.python.validation.PyAnnotator.annotateElement(PyAnnotator.java:46)
    at com.jetbrains.python.validation.PyAnnotatingVisitor.runAnnotators(PyAnnotatingVisitor.java:65)
    at com.jetbrains.python.validation.PyAnnotatingVisitor.annotate(PyAnnotatingVisitor.java:58)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:136)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:116)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.runVisitors(GeneralHighlightingPass.java:336)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectHighlights$5(GeneralHighlightingPass.java:269)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:295)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$6(GeneralHighlightingPass.java:298)
    at com.github.izhangzhihao.rainbow.brackets.visitor.RainbowHighlightVisitor.analyze(RainbowHighlightVisitor.kt:68)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:298)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$6(GeneralHighlightingPass.java:298)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:96)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:298)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:266)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:212)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:84)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:56)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:400)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1137)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:393)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:392)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:368)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:172)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:183)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:366)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:188)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
open-collective-bot[bot] commented 3 years ago

Hey @intellij-rainbow-brackets :wave:,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our https://opencollective.com/intellij-rainbow-brackets and consider backing us - every little helps!

PS.: We offer priority support for all backers. Don't forget to add priority label when you start backing us :smile:

github-actions[bot] commented 3 years ago

This auto generated issue has been automatically marked as wontfix because it's nothing wrong here. If you think there are something really wrong, please reply this issue. Thanks for your cooperation.