async def get_good_q(self, ctx): data = get(url="https://zenquotes.io/api/random") q = json.loads(data.text)[0]["q"] a = json.loads(data.text)[0]["a"] embed = discord.Embed( title="Inspire yeself!", description=f"{ctx.author.mention}, time for some inspiration!", color=Color.dark_teal()) embed.add_field(name=f"Quote by {a}", value=f"{q}", inline=False) await ctx.send(embed=embed)
async def menu(ctx, bot): emoji = ["1️⃣", "2️⃣", "3️⃣", "❌", "✅"] def checkValid(reaction, user): return ( ctx.message.author == user and q.id == reaction.message.id and reaction.emoji in emoji ) embed = discord.Embed(title="GESTION PERSONAE", color=Color.dark_teal()) embed.add_field( name="1️⃣ | Création", value="Permet de débuter la création d'un Persona", inline=False, ) embed.add_field( name="2️⃣ | Édition", value="Permet d'éditer un Persona", inline=False, ) embed.add_field( name="3️⃣ | Suppression", value="Permet de supprimer un Persona", inline=False ) embed.set_footer( text="Cliquez sur la réaction pour choisir !\n ❌ Pour quitter le menu." ) q = await ctx.send(embed=embed) i = 0 while emoji[i] != "✅": await q.add_reaction(emoji[i]) i += 1 reaction, user = await bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "1️⃣": # Création await q.delete() await webhook_create(ctx, bot) return elif reaction.emoji == "2️⃣": # Edition await q.delete() await menu_edit(ctx, bot) return elif reaction.emoji == "3️⃣": # Deletion await q.delete() await gestion.webhook_delete(ctx, bot) return else: await ctx.send("Annulation !") return
EEMSG = 789236911364505600 CPEMSG = 789236918872703018 CSMSG = 789236932693459014 COLORMSG = 789281035657412619 SDMSG = 789241290411868170 WELCOME = 694552494172536833 Color_Emoji = { "<:invisible:789271633343807488>": ["invisible", Color.dark_theme()], "<:greyple:789271633352589352>": ["greyple", Color.greyple()], "<:white:789271633360977960>": ["white", Color.from_rgb(255, 255, 255)], "<:teal:789271633373298718>": ["teal", Color.teal()], "<:darkteal:789271633356521473>": ["darkteal", Color.dark_teal()], "<:darkgreen:789271633336205342>": ["darkgreen", Color.dark_green()], "<:blurple:789271633356783666>": ["blurple", Color.blurple()], "<:darkblue:789271633373954048>": ["darkblue", Color.dark_blue()], "<:darkpurple:789271633386405908>": ["darkpurple", Color.dark_purple()], "<:purple:789271633436737586>": ["purple", Color.purple()], "<:darkorange:789271633332142091>": ["darkorange", Color.dark_orange()], "<:gold:789271633415503902>": ["gold", Color.gold()], } SD_Emoji = { "<:SD0:789240178191368212>": "SD0",
async def admin_rp(self, ctx): await ctx.message.delete() db = sqlite3.connect("src/owlly.db", timeout=3000) c = db.cursor() emoji = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "❌", "✅"] def checkValid(reaction, user): return (ctx.message.author == user and q.id == reaction.message.id and reaction.emoji in emoji) embed = discord.Embed(title="PERSONAE ADMINISTRATION", color=Color.dark_teal()) embed.add_field( name="1️⃣ - Gestion des channels", value="Permet d'ajouter ou supprimers les channels de RP", inline=False, ) embed.add_field( name="2️⃣ - Sticky", value="Permet d'activer ou désactiver le mode sticky.", inline=False, ) embed.add_field( name="3️⃣ - Maximum de personnages", value= "Permet de régler le nombre maximum de personnages autorisés par joueurs.", inline=False, ) embed.add_field( name="4️⃣ - Tag automatique", value= "Permet d'activer un tag avant le nom du personnage, préconfiguré.", inline=False, ) embed.add_field( name="5️⃣ - Token HRP", value="Permet de régler le token pour le HRP.", inline=False, ) embed.add_field( name="6️⃣ - Activation | Désactivation des Personae", value= "Permet de désactiver/activer de manière générale les Personae.", inline=False, ) embed.set_footer( text="Cliquez sur la réaction pour choisir !\n ❌ permet d'annuler. " ) q = await ctx.send(embed=embed) i = 0 while emoji[i] != "✅": await q.add_reaction(emoji[i]) i += 1 reaction, user = await self.bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "1️⃣": await q.clear_reactions() menu_channel = discord.Embed(title=embed.title, color=embed.color) menu_channel.add_field( name="1️⃣ - Ajouter des channels.", value= "Permet de rajouter des channels (ou catégorie) dans la configuration, sans effacer les précédents.", inline=False, ) menu_channel.add_field( name="2️⃣ - Supprimer des channels", value= "Permet de supprimer un channel (ou une catégorie) de la configuration.", inline=False, ) menu_channel.add_field( name="3️⃣ - Reset", value= "Permet d'effacer tous les channels (et/ou catégories) enregistré. ", inline=False, ) await q.edit(embed=menu_channel) await q.add_reaction("1️⃣") await q.add_reaction("2️⃣") await q.add_reaction("3️⃣") await q.add_reaction("❌") reaction, user = await self.bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "1️⃣": await q.delete() await webhook.chanHRP_add(ctx, self.bot) return elif reaction.emoji == "2️⃣": await q.delete() await webhook.chanHRP_rm(ctx, self.bot) return elif reaction.emoji == "3️⃣": await q.delete() db = sqlite3.connect("src/owlly.db", timeout=3000) c = db.cursor() sql = "UPDATE SERVEUR set chanRP=? WHERE idS=?" var = ("0", ctx.guild.id) c.execute(sql, var) db.commit() c.close() db.close() q = await ctx.send( "Il n'y a plus aucun channel enregistrés. Voulez-vous en enregistrer ?" ) await q.add_reaction("✅") await q.add_reaction("❌") reaction, user = await self.bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "✅": await webhook.chanHRP_add(ctx, self.bot) return else: await q.delete() await ctx.send( "Aucun channel n'est configuré.\n Fin de la configuration." ) return elif reaction.emoji == "2️⃣": await q.clear_reactions() menu_sticky = discord.Embed(title=embed.title, color=embed.color) menu_sticky.add_field( name="1️⃣ - Activation", value="Permet d'activer le mode sticky.", inline=False, ) menu_sticky.add_field( name="2️⃣ - Désactivation", value="Permet de désactiver le mode sticky.", inline=False, ) await q.edit(embed=menu_sticky) await q.add_reaction("1️⃣") await q.add_reaction("2️⃣") await q.add_reaction("❌") reaction, user = await self.bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "1️⃣": await q.delete() await webhook.sticky(ctx, self.bot, "0") return elif reaction.emoji == "2️⃣": await q.delete() await webhook.sticky(ctx, self.bot, "1") return else: await q.delete() await ctx.send("Annulation", delete_after=30) return elif reaction.emoji == "3️⃣": await q.clear_reactions() menu = discord.Embed(title=embed.title, color=embed.color) menu.add_field( name="1️⃣ - Désactivation", value="Permet de désactiver la limite.", inline=False, ) menu.add_field( name="2️⃣ - Changement", value="Permet d'éditer la limite.", inline=False, ) await q.edit(embed=embed) await q.add_reaction("1️⃣") await q.add_reaction("2️⃣") await q.add_reaction("❌") reaction, user = await self.bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "1️⃣": await q.delete() await webhook.maxDC(ctx, self.bot, "0") return elif reaction.emoji == "2️⃣": await q.delete() await webhook.maxDC(ctx, self.bot, "1") return else: await q.delete() await ctx.send("Annulation", delete_after=30) return elif reaction.emoji == "4️⃣": await q.clear_reactions() menu = discord.Embed( title=embed.title, color=embed.color, description= "Les tags sont des mots préconfigurés (nom du serveur / nom du joueur / ID du Persona) se plaçant dans le nom du Persona, afin de donner des informations à propos du joueur; serveur ; ou id.", ) menu.add_field( name="1️⃣ - Modification du Tag", value="Permet de modifier ou d'ajouter un tag.", ) menu.add_field(name="2️⃣ - Suppression du tag", value="Permet de supprimer le tag.") await q.edit(embed=menu) await q.add_reaction("1️⃣") await q.add_reaction("2️⃣") await q.add_reaction("❌") reaction, user = await self.bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "1️⃣": await q.delete() await webhook.tag_Personae(ctx, self.bot, "1") elif reaction.emoji == "2️⃣": await q.delete() await webhook.tag_Personae(ctx, self.bot, "0") else: await q.delete() await ctx.send("Annulation, aucun changement effectué.") return elif reaction.emoji == "5️⃣": await q.clear_reactions() menu = discord.Embed(title=embed.title, color=embed.color) menu.add_field( name="1️⃣ - Supprimer le pattern", value="Permet de désactiver la fonction.", inline=False, ) menu.add_field( name="2️⃣ - Changer le pattern", value="Permet d'éditer le pattern HRP.", inline=False, ) await q.edit(embed=menu) await q.add_reaction("1️⃣") await q.add_reaction("2️⃣") await q.add_reaction("❌") reaction, user = await self.bot.wait_for("reaction_add", timeout=300, check=checkValid) if reaction.emoji == "1️⃣": await q.delete() await webhook.tokenHRP(ctx, self.bot, "0") await ctx.send( "Suppression du pattern, la fonction n'est plus configurée." ) return elif reaction.emoji == "2️⃣": await q.delete() await webhook.tokenHRP(ctx, self.bot, "1") await ctx.send("Changement effectué") return else: await q.delete() await ctx.send("Annulation.") return elif reaction.emoji == "6️⃣": await q.delete() db = sqlite3.connect("src/owlly.db", timeout=3000) c = db.cursor() sql = "SELECT maxDC FROM SERVEUR WHERE idS = ?" c.execute(sql, (ctx.guild.id, )) maxDC = c.fetchone() if maxDC is None: maxDC = "0" else: maxDC = maxDC[0] if maxDC != -1: phrase = "Désactivation des Personae" config = -1 elif maxDC == -1: phrase = "Activation des Personae" config = 0 q = await ctx.send(f"{phrase}\nSouhaitez-vous continuer ?") await q.add_reaction("✅") await q.add_reaction("❌") reaction, user = await self.bot.wait_for("add_reaction", timeout=300, check=checkValid) if reaction.emoji == "✅": await q.delete() utils = self.bot.get_cog("DB_utils") await utils.init_value("maxDC", "SERVEUR", "idS", config, ctx.guild.id) await ctx.send("Modification enregistrée.") return else: await q.delete() await ctx.send("Annulation", delete_after=30) return else: await q.delete() await ctx.send("Annulation !", delete_after=30) return
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