Added clean, newmember, purge, readrules and restart.
This commit is contained in:
parent
33e662d683
commit
071078810b
19
modules/clean/__init__.py
Normal file
19
modules/clean/__init__.py
Normal file
@ -0,0 +1,19 @@
|
||||
from modules.base import BaseClassPython
|
||||
|
||||
class MainClass(BaseClassPython):
|
||||
name = "clean"
|
||||
authorized_roles=[522918472548745217]
|
||||
help = {
|
||||
"description": "Supprime des messages",
|
||||
"commands": {
|
||||
"`{prefix}{command}`": "Supprime tous les messages du bot dans le salon"
|
||||
}
|
||||
}
|
||||
command_text = "clean"
|
||||
|
||||
async def command(self, message, args, kwargs):
|
||||
def is_me(m):
|
||||
return m.author == self.client.user
|
||||
|
||||
deleted = await message.channel.purge(limit=10000000, check=is_me)
|
||||
await message.channel.send('Deleted {} message(s)'.format(len(deleted)))
|
11
modules/clean/version.json
Normal file
11
modules/clean/version.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version":"0.1.0",
|
||||
"type": "python",
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"bot_version": {
|
||||
"min": "0.1.0",
|
||||
"max": "0.1.0"
|
||||
}
|
||||
}
|
34
modules/newmember/__init__.py
Normal file
34
modules/newmember/__init__.py
Normal file
@ -0,0 +1,34 @@
|
||||
import discord
|
||||
import sys
|
||||
from modules.base import BaseClassPython
|
||||
|
||||
|
||||
class MainClass(BaseClassPython):
|
||||
name = "NewMember"
|
||||
color = 0xff071f
|
||||
help_active = False
|
||||
help = {
|
||||
"description": "Module d'accueil",
|
||||
"commands": {
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, client):
|
||||
super().__init__(client)
|
||||
self.config.init({"new_role":430845952388104212,
|
||||
"guild":297780867286433792,
|
||||
"motd":"Bienvenue sur le serveur de la communauté d'E-penser. Nous vous prions de lire le règlement afin d'accéder au serveur complet."})
|
||||
|
||||
async def on_ready(self):
|
||||
guild = self.client.get_guild(self.config.guild)
|
||||
for i, member in enumerate(guild.members):
|
||||
if len(member.roles) == 1:
|
||||
await member.add_roles(await self.client.id.get_role(id_=self.config.new_role,
|
||||
guild=guild))
|
||||
if i%50==0:
|
||||
print(i, member)
|
||||
|
||||
async def on_member_join(self, member):
|
||||
await member.add_roles(await self.client.id.get_role(id_=self.config.new_role,
|
||||
guild=self.client.get_guild(self.config.guild)))
|
||||
await member.send(self.config.motd)
|
11
modules/newmember/version.json
Normal file
11
modules/newmember/version.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version":"0.1.0",
|
||||
"type": "python",
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"bot_version": {
|
||||
"min": "0.1.0",
|
||||
"max": "0.1.0"
|
||||
}
|
||||
}
|
41
modules/purge/__init__.py
Normal file
41
modules/purge/__init__.py
Normal file
@ -0,0 +1,41 @@
|
||||
import discord
|
||||
import sys
|
||||
from modules.base import BaseClassPython
|
||||
|
||||
class MainClass(BaseClassPython):
|
||||
name = "Purge"
|
||||
color = 0xff0004
|
||||
help_active = True
|
||||
authorized_roles=[522918472548745217]
|
||||
help = {
|
||||
"description": "Suppression de messages en block.",
|
||||
"commands": {
|
||||
"`{prefix}{command} <message_id>`": "Supprime tous les messages du salon jusqu'au message spécifié",
|
||||
}
|
||||
}
|
||||
command_text = "purge"
|
||||
|
||||
async def command(self, message, args, kwargs):
|
||||
message_id = None
|
||||
try:
|
||||
message_id = int(args[0])
|
||||
except ValueError:
|
||||
pass
|
||||
if len(args) and message_id is not None:
|
||||
messages_list=[]
|
||||
done=False
|
||||
async for current in message.channel.history(limit=None):
|
||||
if int(current.id) == message_id:
|
||||
done = True
|
||||
break
|
||||
elif message.id != current.id:
|
||||
messages_list.append(current)
|
||||
if done:
|
||||
chunks = [messages_list[x:x+99] for x in range(0, len(messages_list), 99)]
|
||||
for chunk in chunks:
|
||||
await message.channel.delete_messages(chunk)
|
||||
await message.channel.send(f"**{len(messages_list)}** messages supprimés.")
|
||||
else:
|
||||
await message.channel.send("Le message spécifié n'a pas été trouvé.")
|
||||
else:
|
||||
await message.channel.send("Arguments invalides.")
|
11
modules/purge/version.json
Normal file
11
modules/purge/version.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version":"0.1.0",
|
||||
"type": "python",
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"bot_version": {
|
||||
"min": "0.1.0",
|
||||
"max": "0.1.0"
|
||||
}
|
||||
}
|
37
modules/readrules/__init__.py
Normal file
37
modules/readrules/__init__.py
Normal file
@ -0,0 +1,37 @@
|
||||
import discord
|
||||
import sys
|
||||
from modules.base import BaseClassPython
|
||||
|
||||
|
||||
class MainClass(BaseClassPython):
|
||||
name = "ReadRules"
|
||||
color = 0xff071f
|
||||
help_active = False
|
||||
help = {
|
||||
"description": "Module d'accueil",
|
||||
"commands": {
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, client):
|
||||
super().__init__(client)
|
||||
self.config.init({"accepted_role":430846685380345876,
|
||||
"new_role":430845952388104212,
|
||||
"listen_chan":430995739636793345,
|
||||
"log_chan":429977240202248192,
|
||||
"passwords":["cacahuète","cacahuete","cacahuètes","cacahuetes"],
|
||||
"succes_pm":"Félicitations, vous êtes désormais un **e-penseur** accompli. Bienvenue sur le serveur E-penser.",
|
||||
"succes":" est désormais un **e-penseur** accompli."})
|
||||
|
||||
async def on_message(self, message):
|
||||
if message.channel.id == self.config.listen_chan:
|
||||
if message.content.lower() in self.config.passwords:
|
||||
new_role = await self.client.id.get_role(id_=self.config.new_role, guild=message.channel.guild)
|
||||
if new_role in message.author.roles:
|
||||
await message.author.remove_roles(new_role)
|
||||
await message.author.add_roles(await self.client.id.get_role(id_=self.config.accepted_role,
|
||||
guild=message.channel.guild))
|
||||
await message.author.send(self.config.succes_pm)
|
||||
await message.channel.guild.get_channel(self.config.log_chan).send(message.author.mention + self.config.succes)
|
||||
else:
|
||||
await message.author.send(f"Le mot de passe que vous avez entré est incorrect : `{message.content}`.\nNous vous prions de lire le règlement afin d'accéder au serveur complet.")
|
11
modules/readrules/version.json
Normal file
11
modules/readrules/version.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version":"0.1.0",
|
||||
"type": "python",
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"bot_version": {
|
||||
"min": "0.1.0",
|
||||
"max": "0.1.0"
|
||||
}
|
||||
}
|
22
modules/restart/__init__.py
Normal file
22
modules/restart/__init__.py
Normal file
@ -0,0 +1,22 @@
|
||||
import discord
|
||||
import sys
|
||||
from modules.base import BaseClassPython
|
||||
|
||||
|
||||
class MainClass(BaseClassPython):
|
||||
name = "Restart"
|
||||
color = 0xff071f
|
||||
help_active = True
|
||||
authorized_roles = [431043517217898496]
|
||||
help = {
|
||||
"description": "Module gérant les redémarrages de Nikola Tesla",
|
||||
"commands": {
|
||||
"`{prefix}{command}`": "Redémarre le bot.",
|
||||
}
|
||||
}
|
||||
command_text = "restart"
|
||||
|
||||
async def command(self, message, args, kwargs):
|
||||
await message.channel.send(f"{message.author.mention}, Le bot va redémarrer.")
|
||||
await self.client.logout()
|
||||
sys.exit(0)
|
11
modules/restart/version.json
Normal file
11
modules/restart/version.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version":"0.1.0",
|
||||
"type": "python",
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"bot_version": {
|
||||
"min": "0.1.0",
|
||||
"max": "0.1.0"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user