diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..e2cb111 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 4c49bd7..8661818 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .env +.vscode diff --git a/__pycache__/error_handler.cpython-38.pyc b/__pycache__/error_handler.cpython-38.pyc index 72db757..4b5a990 100644 Binary files a/__pycache__/error_handler.cpython-38.pyc and b/__pycache__/error_handler.cpython-38.pyc differ diff --git a/__pycache__/help_command.cpython-38.pyc b/__pycache__/help_command.cpython-38.pyc index 33feff2..68f8384 100644 Binary files a/__pycache__/help_command.cpython-38.pyc and b/__pycache__/help_command.cpython-38.pyc differ diff --git a/bot.py b/bot.py index 813ef59..8741e22 100644 --- a/bot.py +++ b/bot.py @@ -8,6 +8,12 @@ from dotenv import load_dotenv from discord.utils import get + +intents = discord.Intents.default() +intents.members = True +client2 = discord.Client(intents = intents) +#client2=discord.Client(intents=intents) + #Load TOKEN load_dotenv() token=os.getenv('BOT_TOKEN') @@ -15,6 +21,7 @@ #Prefix client = commands.Bot(command_prefix='--') + #Approved roles to make few changes approved_roles=['admin','mesa'] other_roles=['@everyone','Colmillo'] @@ -25,9 +32,22 @@ client.load_extension('error_handler') #Event when connected -@client.event +@client2.event async def on_ready(): await client.change_presence(status=discord.Status.online, activity=discord.Game('ITAM4Code')) + print('loggeado como') + print(client.user.name) + print(client.user.id) + +# enviar un mensaje de bienvenida: +newUserMessage = """ Bienvenido colega!""" + +@client2.event +async def on_member_join(member): + guild = client2.get_guild(821699949493485578) + channel = guild.get_channel(821699949493485581) + await channel.send(newUserMessage + f' {member.mention} ! :partying_face:') + await member.send(f'Welcome to the {guild.name} server, {member.name}! :partying_face:') #Version command @client.command(name='version') @@ -39,7 +59,7 @@ async def version(context): embed.set_author(name="ITAM4Code") await context.message.channel.send(embed=embed) -#Create project command +#Create project command (solo puede hacerlo el admin) @client.command(name='new_project') async def create_project(context, args): user=context.message.author @@ -49,7 +69,7 @@ async def create_project(context, args): return perms=discord.Permissions(send_messages=True, read_messages=True, embed_links=True, external_emojis=True, read_message_history=True, speak=True, use_external_emojis=True, use_voice_activation=True, view_channel=True, change_nickname=True, - attach_files=True, add_reactions=True,mention_everyone=True, connect=True, stream=True) + attach_files=True, add_reactions=True,mention_everyone=True, connect=True, stream=True, manage_roles = True) await context.message.channel.send('Creando nuevo rol con nombre: '+args+' con permisos: '+str(perms)) await context.guild.create_role(name=args,permissions=perms) await context.message.channel.send('Creando nuevo canal para el rol: '+args) @@ -61,6 +81,8 @@ async def create_project(context, args): else: await context.message.channel.send('No eres administrador del servidor, no puedes crear nuevos proyectos') + + async def make_channel(context,name): guild=context.guild admin=get(guild.roles,name=approved_roles[0]) #mesa en caso de usar el server de la OE @@ -103,6 +125,26 @@ async def show_available_roles(context): embed.add_field(name="Proyecto: "+role.name, value=role.id) await context.message.channel.send(embed=embed) + +#Abandonar proyecto, sin que se elimine el proyecto completo +@client.command(name = 'my_info') #passing context +async def salute(ctx): #context gets passed into the first parameter + embed = discord.Embed(title="Informacion usuario", description="", color=0x00ff00) + embed.add_field(name="Autor:", value = ctx.message.author) + embed.add_field(name="ID", value = ctx.author.id) + embed.add_field(name="Canal", value = ctx.message.channel) + await ctx.send(embed=embed) + + + + +@client.command(name = 'leave') +async def remove(ctx, role: discord.Role, user: discord.Member): + if ctx.author.guild_permissions.administrator: + await user.remove_roles(role) + await ctx.send("Eliminación de Rol exitoso") + + #Test command @client.command(name='test') async def test(ctx, arg): @@ -120,6 +162,26 @@ async def inspire(ctx): quote = get_quote() await ctx.send(quote) +@client.command(name='emoji') +async def emoji(ctx): + await ctx.send("🔥") + await ctx.send(":noice:") + await ctx.send("<:67069a13e006345ce28ecc581f2ed162>") + + + + + +#@client.event +#async def on_member_leave(member): + # print("Recognised that a member called " + member.name + " left") + # embed=discord.Embed(title=" Goodbye "+member.name+"!", description="Until we meet again old friend.", color=0x00ff00) #Run client +#embed=discord.Embed(title= "Informacion usuario", description="Bienvenido", color=0x00ff00) client.run(token) +client2.run(token) + +# puedo tener dos clients? + + \ No newline at end of file diff --git a/help_command.py b/help_command.py index 01975cc..6901128 100644 --- a/help_command.py +++ b/help_command.py @@ -60,6 +60,22 @@ async def inspire(self,context): await context.channel.send(embed=embed) @help.command() + async def leave(self,context): + embed= discord.Embed(title="leave", description= "Comando para que un usuario abandone el rol de un proyecto",color=0x00ff00) + embed.add_field(name="**Syntax**", value="--leave [nombre del proyecto] [ID del usuario]") + embed.add_field(name="Permissions", value="All Users") + embed.set_author(name="ITAM4Code") + await context.channel.send(embed=embed) + + @help.command() + async def my_info(self,context): + embed= discord.Embed(title="my_info", description= "Obtener tu información de usuario",color=0x00ff00) + embed.add_field(name="**Syntax**", value="--my_info") + embed.add_field(name="Permissions", value="All Users") + embed.set_author(name="ITAM4Code") + await context.channel.send(embed=embed) + + async def close_project(self,context): embed= discord.Embed(title="close_project", description= "Elimina el rol asignado al proyecto para que nadie más pueda ingresar. El canal de texto se queda abierto por si se retoma el proyecto",color=0x00ff00) embed.add_field(name="**Syntax**", value="--close_project [nombre del proyecto/rol]") @@ -75,5 +91,8 @@ async def show_projects(self,context): embed.set_author(name="ITAM4Code") await context.channel.send(embed=embed) + + + def setup(bot): bot.add_cog(Help(bot)) \ No newline at end of file