Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
.vscode
Binary file modified __pycache__/error_handler.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/help_command.cpython-38.pyc
Binary file not shown.
68 changes: 65 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
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')

#Prefix
client = commands.Bot(command_prefix='--')


#Approved roles to make few changes
approved_roles=['admin','mesa']
other_roles=['@everyone','Colmillo']
Expand All @@ -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')
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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?



19 changes: 19 additions & 0 deletions help_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand All @@ -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))