Example #1
0
 async def nom(self, ctx, nom, new):
     id = gestion.search_Persona(ctx, nom)
     tag = gestion.name_persona(ctx, new, id)
     check = gestion.name_check(ctx, tag)
     if check == "error":
         await ctx.send("Ce nom est déjà pris !")
         return
     db = sqlite3.connect("src/owlly.db", timeout=3000)
     c = db.cursor()
     sql = "UPDATE DC SET Nom = ? WHERE (idS=? AND idDC = ? AND Nom = ?)"
     var = (tag, ctx.guild.id, id, nom)
     c.execute(sql, var)
     await ctx.send("Le nom a été mis à jour !")
     db.commit()
     c.close()
     db.close()
Example #2
0
    async def token(self, ctx, nom):
        db = sqlite3.connect("src/owlly.db", timeout=3000)
        c = db.cursor()

        id = gestion.search_Persona(ctx, nom)
        token = gestion.token_Persona(ctx, self.bot)
        check = gestion.check_token(ctx, token)
        if check == "error":
            await ctx.send("Ce token est déjà pris !")
            return
        sql = "UPDATE DC SET token=? WHERE idDC = ?"
        var = (token, id)
        c.execute(sql, var)
        db.commit()
        c.close()
        db.close()
        return
Example #3
0
 async def delete(self, ctx, persona):
     db = sqlite3.connect("src/owlly.db", timeout=3000)
     c = db.cursor()
     id = gestion.search_Persona(ctx, persona)
     if id == "error":
         await ctx.send("Ce Persona n'existe pas")
         return
     sql = "DELETE FROM DC WHERE (idS = ? AND idU = ? AND idDC = ?)"
     var = (
         ctx.guild.id,
         ctx.message.author.id,
         id,
     )
     c.execute(sql, var)
     await ctx.send("La suppression a bien été effectuée !")
     db.commit()
     c.close()
     db.close()
     return
Example #4
0
    async def image(self, ctx, nom):
        db = sqlite3.connect("src/owlly.db", timeout=3000)
        c = db.cursor()

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

        idC = gestion.search_Persona(ctx, nom)
        if idC == "error":
            await ctx.send("Erreur ! Ce Persona est introuvable.")
            return
        await ctx.send("Merci d'envoyer l'image (lien ou fichier)")
        rep = await self.bot.wait_for("message", timeout=300, check=checkRep)
        image = await gestion.image_persona(ctx, self.bot, rep)
        if image == "stop":
            return
        sql = "UPDATE DC SET Avatar = ? WHERE idDC = ?"
        var = (image, idC)
        c.execute(sql, var)
        db.commit()
        c.close()
        db.close()
        return
Example #5
0
async def menu_edit(ctx, bot):
    emoji = ["1️⃣", "2️⃣", "3️⃣", "❌", "✅"]

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

    def checkValid(reaction, user):
        return (
            ctx.message.author == user
            and q.id == reaction.message.id
            and reaction.emoji in emoji
        )

    edition = discord.Embed(title="PERSONAE - ÉDITION", color=Color.dark_teal())
    edition.add_field(
        name="1️⃣ | Nom",
        value="Édition du nom",
        inline=False,
    )
    edition.add_field(name="2️⃣ | Avatar", value="Édition de l'avatar", inline=False)
    edition.add_field(name="3️⃣ | Token", value="Édition du token", inline=False)
    edition.set_footer(
        text="Cliquez sur la réaction pour choisir !\n ❌ Pour quitter le menu."
    )
    q = await ctx.send(embed=edition)
    await q.add_reaction("1️⃣")
    await q.add_reaction("2️⃣")
    await q.add_reaction("3️⃣")
    await q.add_reaction("❌")
    reaction, user = await bot.wait_for("reaction_add", timeout=300, check=checkValid)
    if reaction.emoji == "1️⃣":
        await q.delete()
        q = await ctx.send(
            "Merci d'envoyer le nom ou le token du personnage que vous voulez éditer."
        )
        rep = await bot.wait_for("message", timeout=300, check=checkRep)
        persona = rep.content
        if rep.content.lower() == "stop" or rep.content.lower() == "cancel":
            await ctx.send("Annulation !", delete_after=30)
            await q.delete()
            await rep.delete()
            return
        idDC = gestion.search_Persona(ctx, persona)
        if idDC == "error":
            await ctx.send("Erreur ! Ce Persona n'existe pas.")
            return
        await webhook_edit(ctx, bot, idDC, "1")
        return
    elif reaction.emoji == "2️⃣":
        await q.delete()
        q = await ctx.send(
            "Merci d'envoyer le nom ou le token du personnage que vous voulez éditer."
        )
        rep = await bot.wait_for("message", timeout=300, check=checkRep)
        persona = rep.content
        if rep.content.lower() == "stop" or rep.content.lower() == "cancel":
            await ctx.send("Annulation !", delete_after=30)
            await q.delete()
            await rep.delete()
            return
        idDC = gestion.search_Persona(ctx, persona)
        if idDC == "error":
            await ctx.send("Erreur ! Ce Persona n'existe pas.")
            return
        await webhook_edit(ctx, bot, idDC, "2")
        return
    elif reaction.emoji == "3️⃣":
        await q.delete()
        q = await ctx.send(
            "Merci d'envoyer le nom ou le token du personnage que vous voulez éditer."
        )
        rep = await bot.wait_for("message", timeout=300, check=checkRep)
        persona = rep.content
        if rep.content.lower() == "stop" or rep.content.lower() == "cancel":
            await ctx.send("Annulation !", delete_after=30)
            await q.delete()
            await rep.delete()
            return
        idDC = gestion.search_Persona(ctx, persona)
        if idDC == "error":
            await ctx.send("Erreur ! Ce Persona n'existe pas.")
            return
        await webhook_edit(ctx, bot, idDC, "3")
        return
    else:
        await q.delete()
        await ctx.send("Annulation !")
        return