Add translation for english
reapair config loading system (int are forbidden in json keys 😠 )
This commit is contained in:
parent
bd74f13f96
commit
2e2716bfd5
8
main.py
8
main.py
@ -62,8 +62,9 @@ class Guild():
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.config_file = config_file
|
self.config_file = config_file
|
||||||
self.config = {"modules": ["modules"],
|
self.config = {"modules": ["modules"],
|
||||||
"prefixe": "¤",
|
"prefixe": "ยง",
|
||||||
"master_admin": [318866596502306816],
|
"master_admin": [318866596502306816],
|
||||||
|
"lang":"FR_fr"
|
||||||
}
|
}
|
||||||
self.modules = []
|
self.modules = []
|
||||||
self.load_config()
|
self.load_config()
|
||||||
@ -92,7 +93,8 @@ class Guild():
|
|||||||
errors = []
|
errors = []
|
||||||
if "modules" not in self.config["modules"]:
|
if "modules" not in self.config["modules"]:
|
||||||
self.config["modules"].append("modules")
|
self.config["modules"].append("modules")
|
||||||
for module in self.config["modules"]:
|
module_to_load = self.config["modules"]
|
||||||
|
for module in module_to_load:
|
||||||
# Try to load all modules by name
|
# Try to load all modules by name
|
||||||
if module not in self.bot.modules.keys():
|
if module not in self.bot.modules.keys():
|
||||||
# Module is not an existing module
|
# Module is not an existing module
|
||||||
@ -195,4 +197,4 @@ class FoBot(discord.Client):
|
|||||||
|
|
||||||
|
|
||||||
myBot = FoBot()
|
myBot = FoBot()
|
||||||
myBot.run("NDcwNzI4NjAzMDEzNzQyNjAy.Dj3Ysg.ivUV-SNiYr0KlkHKiZqtfoD2WQ8", max_messages=100000000)
|
myBot.run("", max_messages=100000000)
|
||||||
|
@ -1,30 +1,9 @@
|
|||||||
import discord
|
import discord
|
||||||
|
import traductions as tr
|
||||||
|
|
||||||
|
|
||||||
class MainClass:
|
class MainClass:
|
||||||
name = "modules"
|
name = "modules"
|
||||||
description = "Permet de gérer les modules."
|
|
||||||
aide = {
|
|
||||||
"list_modules": {
|
|
||||||
"description":"Permet de lister les modules disponibles. Les modules en gras sont actifs.",
|
|
||||||
"exemples":[
|
|
||||||
("`list_modules`", "Liste tous les modules"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"load": {
|
|
||||||
"description":"Commande permetant de charger des modules.",
|
|
||||||
"exemples":[
|
|
||||||
("`load fun`", "Charge le module fun"),
|
|
||||||
("`load fun admin`", "Charge les modules fun et admin"),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unload": {
|
|
||||||
"description":"Commande permetant de décharger des modules.",
|
|
||||||
"exemples":[
|
|
||||||
("`unload fun`", "Décharge le module fun"),
|
|
||||||
("`unload fun admin`", "Décharge les modules fun et admin"),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, guild):
|
def __init__(self, guild):
|
||||||
self.guild = guild
|
self.guild = guild
|
||||||
@ -34,33 +13,42 @@ class MainClass:
|
|||||||
errors = []
|
errors = []
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if args not in self.guild.config["modules"]:
|
if args not in self.guild.config["modules"]:
|
||||||
self.guild.config["modules"].append(args[0])
|
self.guild.config["modules"].append(arg)
|
||||||
errors.extend(self.guild.update_modules())
|
errors.extend(self.guild.update_modules())
|
||||||
if errors:
|
if errors:
|
||||||
textes = [
|
texts = [
|
||||||
("Erreur lors de l'activation du module %s:" % module,
|
(tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["error"]["name"] % module,
|
||||||
"Celui-ci n'existe pas. Tapez %slist_modules pour voir la liste des modules disponibles" %
|
tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["error"]["value"] %
|
||||||
self.guild.config["prefixe"])
|
self.guild.config["prefixe"])
|
||||||
for module in errors
|
for module in errors
|
||||||
]
|
]
|
||||||
embed = discord.Embed(title="Erreur")
|
embed = discord.Embed(
|
||||||
for erreur in textes:
|
title=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["error"]["title"])
|
||||||
embed.add_field(name=erreur[0], value=erreur[1], inline=False)
|
for error in texts:
|
||||||
|
embed.add_field(name=error[0], value=error[1], inline=False)
|
||||||
await msg.channel.send(embed=embed)
|
await msg.channel.send(embed=embed)
|
||||||
self.guild.save_config()
|
self.guild.save_config()
|
||||||
else:
|
else:
|
||||||
embed = discord.Embed(title="Erreur")
|
embed = discord.Embed(
|
||||||
|
title=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["permissionError"]["title"])
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
embed.add_field(name="Erreur lors du chargement du module.",
|
embed.add_field(
|
||||||
value="Vous n'avez pas la permission de charger un module.")
|
name=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["permissionError"]["one"][
|
||||||
|
"name"],
|
||||||
|
value=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["permissionError"]["one"][
|
||||||
|
"value"])
|
||||||
else:
|
else:
|
||||||
embed.add_field(name="Erreur lors du chargement des modules.",
|
embed.add_field(
|
||||||
value="Vous n'avez pas la permission de charger des modules.")
|
name=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["permissionError"]["many"][
|
||||||
|
"name"],
|
||||||
|
value=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["load"]["permissionError"]["many"][
|
||||||
|
"value"])
|
||||||
await msg.channel.send(embed=embed)
|
await msg.channel.send(embed=embed)
|
||||||
|
return
|
||||||
|
|
||||||
async def unload(self, msg, command, args):
|
async def unload(self, msg, command, args):
|
||||||
if msg.author.id in self.guild.config["master_admin"]:
|
if msg.author.id in self.guild.config["master_admin"]:
|
||||||
errors=[]
|
errors = []
|
||||||
for arg in args:
|
for arg in args:
|
||||||
try:
|
try:
|
||||||
self.guild.config["modules"].remove(arg)
|
self.guild.config["modules"].remove(arg)
|
||||||
@ -70,44 +58,57 @@ class MainClass:
|
|||||||
errors.extend(self.guild.update_modules())
|
errors.extend(self.guild.update_modules())
|
||||||
if errors:
|
if errors:
|
||||||
textes = [
|
textes = [
|
||||||
("Erreur lors de la désactivation du module %s:" % module,
|
(tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["error"]["name"] % module,
|
||||||
"Celui-ci n'existe pas ou n'est pas activé. Tapez %slist_modules pour voir la liste des modules disponibles" %
|
tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["error"]["value"] %
|
||||||
self.guild.config["prefixe"])
|
self.guild.config["prefixe"])
|
||||||
for module in errors
|
for module in errors
|
||||||
]
|
]
|
||||||
embed = discord.Embed(title="Erreur")
|
embed = discord.Embed(
|
||||||
|
title=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["error"]["title"])
|
||||||
for erreur in textes:
|
for erreur in textes:
|
||||||
embed.add_field(name=erreur[0], value=erreur[1], inline=False)
|
embed.add_field(name=erreur[0], value=erreur[1], inline=False)
|
||||||
await msg.channel.send(embed=embed)
|
await msg.channel.send(embed=embed)
|
||||||
self.guild.save_config()
|
self.guild.save_config()
|
||||||
else:
|
else:
|
||||||
embed = discord.Embed(title="Erreur")
|
embed = discord.Embed(
|
||||||
|
title=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["permissionError"][
|
||||||
|
"title"])
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
embed.add_field(name="Erreur lors du chargement du module.",
|
embed.add_field(
|
||||||
value="Vous n'avez pas la permission de charger un module.")
|
name=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["permissionError"]["one"][
|
||||||
|
"name"],
|
||||||
|
value=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["permissionError"]["one"][
|
||||||
|
"value"])
|
||||||
else:
|
else:
|
||||||
embed.add_field(name="Erreur lors du chargement des modules.",
|
embed.add_field(
|
||||||
value="Vous n'avez pas la permission de charger des modules.")
|
name=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["permissionError"]["many"][
|
||||||
|
"name"],
|
||||||
|
value=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["unload"]["permissionError"]["many"][
|
||||||
|
"value"])
|
||||||
await msg.channel.send(embed=embed)
|
await msg.channel.send(embed=embed)
|
||||||
|
return
|
||||||
|
|
||||||
async def list_modules(self, msg, command, args):
|
async def list_modules(self, msg, command, args):
|
||||||
embed = discord.Embed(title="Liste des modules")
|
embed = discord.Embed(title=tr.tr[self.guild.config["lang"]]["modules"]["modules"]["list_modules"]["title"])
|
||||||
for module, classe in self.guild.bot.modules.items():
|
for module, classe in self.guild.bot.modules.items():
|
||||||
if module not in self.guild.config["modules"]:
|
if module not in self.guild.config["modules"]:
|
||||||
embed.add_field(name=classe.name+":", value=classe.description, inline=False)
|
embed.add_field(name=classe.name + ":",
|
||||||
|
value=tr.tr[self.guild.config["lang"]]["modules"][classe.name]["description"],
|
||||||
|
inline=False)
|
||||||
else:
|
else:
|
||||||
embed.add_field(name="***"+classe.name + "***:", value=classe.description, inline=False)
|
embed.add_field(name="***" + classe.name + "***:",
|
||||||
|
value=tr.tr[self.guild.config["lang"]]["modules"][classe.name]["description"],
|
||||||
|
inline=False)
|
||||||
await msg.channel.send(embed=embed)
|
await msg.channel.send(embed=embed)
|
||||||
|
return
|
||||||
|
|
||||||
async def on_message(self, msg):
|
async def on_message(self, msg):
|
||||||
if msg.content.startswith(self.guild.config["prefixe"]):
|
if msg.content.startswith(self.guild.config["prefixe"]):
|
||||||
command, *args = msg.content.lstrip(self.guild.config["prefixe"]).split(" ")
|
command, *args = msg.content.lstrip(self.guild.config["prefixe"]).split(" ")
|
||||||
print(command, args)
|
|
||||||
if command == "load":
|
if command == "load":
|
||||||
await self.load(msg, command, args)
|
await self.load(msg, command, args)
|
||||||
elif command == "list_modules":
|
elif command == "list_modules":
|
||||||
await self.list_modules(msg, command, args)
|
await self.list_modules(msg, command, args)
|
||||||
elif command == "unload":
|
elif command == "unload":
|
||||||
await self.unload(msg, command, args)
|
await self.unload(msg, command, args)
|
||||||
|
return
|
||||||
|
|
||||||
|
138
traductions.py
Normal file
138
traductions.py
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
tr = {
|
||||||
|
"FR_fr": {
|
||||||
|
"modules": {
|
||||||
|
"modules": {
|
||||||
|
"description": "Permet de gérer les modules.",
|
||||||
|
"aide": {
|
||||||
|
"list_modules": {
|
||||||
|
"description": "Liste tous les modules. Les modules en gras sont activés.",
|
||||||
|
"exemples": [
|
||||||
|
("`list_modules`", "Liste tous les modules"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"load": {
|
||||||
|
"description": "Permet de charger un ou des modules.",
|
||||||
|
"exemples": [
|
||||||
|
("`load fun`", "Charge le module fun"),
|
||||||
|
("`load fun admin`", "Charge les modules fun et admin"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"unload": {
|
||||||
|
"description": "Permet de décharger un ou des modules.",
|
||||||
|
"exemples": [
|
||||||
|
("`unload fun`", "Décharge le module fun"),
|
||||||
|
("`unload fun admin`", "Décharge les modules fun et admin"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"list_modules": {
|
||||||
|
"title": "Liste des modules",
|
||||||
|
},
|
||||||
|
"load": {
|
||||||
|
"error": {
|
||||||
|
"name": "Erreur lors de l'activation du module %s:",
|
||||||
|
"value": "Celui-ci n'existe pas. Tapez %slist_modules pour voir la liste des modules disponibles.",
|
||||||
|
"title": "Erreur",
|
||||||
|
},
|
||||||
|
"permissionError": {
|
||||||
|
"title": "Erreur",
|
||||||
|
"one": {
|
||||||
|
"name": "Erreur lors du chargement du module.",
|
||||||
|
"value": "Vous n'avez pas la permission de charger un module.",
|
||||||
|
},
|
||||||
|
"many": {
|
||||||
|
"name": "Erreur lors du chargement des modules.",
|
||||||
|
"value": "Vous n'avez pas la permission de charger des modules."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unload": {
|
||||||
|
"error": {
|
||||||
|
"name": "Erreur lors de la désactivation du module %s:",
|
||||||
|
"value": "Celui-ci n'existe pas ou n'est pas activé. Tapez %slist_modules pour voir la liste des modules disponibles.",
|
||||||
|
"title": "Erreur",
|
||||||
|
},
|
||||||
|
"permissionError": {
|
||||||
|
"title": "Erreur",
|
||||||
|
"one": {
|
||||||
|
"name": "Erreur lors de la désactivation du module.",
|
||||||
|
"value": "Vous n'avez pas la permission de désactiver un module.",
|
||||||
|
},
|
||||||
|
"many": {
|
||||||
|
"name": "Erreur lors de la désactivation des modules.",
|
||||||
|
"value": "Vous n'avez pas la permission de désactiver des modules."
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"EN_us": {
|
||||||
|
"modules": {
|
||||||
|
"modules": {
|
||||||
|
"description": "Allow to manage modules.",
|
||||||
|
"aide": {
|
||||||
|
"list_modules": {
|
||||||
|
"description": "Lists all modules. Modules in bold are enabled.",
|
||||||
|
"exemples": [
|
||||||
|
("`list_modules`", "Lists all modules"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"load": {
|
||||||
|
"description": "Load one or more modules.",
|
||||||
|
"examples": [
|
||||||
|
("`load fun`", "Load fun module"),
|
||||||
|
("`load fun admin`", "Load fun and admin modules"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"unload": {
|
||||||
|
"description": "Unload one or more modules.",
|
||||||
|
"exemples": [
|
||||||
|
("`load fun`", "Unload fun module"),
|
||||||
|
("`upload fun admin`", "Unload fun and admin modules"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"list_modules": {
|
||||||
|
"title": "List of modules"
|
||||||
|
},
|
||||||
|
"load": {
|
||||||
|
"error": {
|
||||||
|
"name": "Error when activating the %s module:",
|
||||||
|
"value": "This one doesn't exist. Type %slist_modules to see the list of available modules.",
|
||||||
|
"title": "Error",
|
||||||
|
},
|
||||||
|
"permissionError": {
|
||||||
|
"title": "Error",
|
||||||
|
"one": {
|
||||||
|
"name": "Error when loading the module.",
|
||||||
|
"value": "You do not have permission to load a module.",
|
||||||
|
},
|
||||||
|
"many": {
|
||||||
|
"name": "Error when loading modules.",
|
||||||
|
"value": "You do not have permission to load modules.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"unload": {
|
||||||
|
"error": {
|
||||||
|
"name": "Error when deactivating the %s module:",
|
||||||
|
"value": "This one doesn't exist or isn't activate. Type %slist_modules to see the list of available modules.",
|
||||||
|
"title": "Error",
|
||||||
|
},
|
||||||
|
"permissionError": {
|
||||||
|
"title": "Error",
|
||||||
|
"one": {
|
||||||
|
"name": "Error when deactivating the module.",
|
||||||
|
"value": "You do not have permission to deactivate a module.",
|
||||||
|
},
|
||||||
|
"many": {
|
||||||
|
"name": "Error when deactivate modules.",
|
||||||
|
"value": "You do not have permission to deactivate modules.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user