Recuerda que en las ciencias informáticas cualquier problema casi siempre tiene varias soluciones, por lo tanto nosotros enseñaremos la mejor y más óptimo.
Ejemplo 1: cómo hacer un pitón de bot de discordia
# pip install discordimport discord
classMyClient(discord.Client):asyncdefon_connect(self):print('[LOGS] Connecting to discord!')asyncdefon_ready(self):print('[LOGS] Bot is ready!')print("""[LOGS] Logged in: n[LOGS] ID: n[LOGS] Number of users: """.format(self.bot.user.name, self.bot.user.id,len(set(self.bot.get_all_members()))))await self.bot.change_presence(activity=discord.Game(name="Weeke is a god!"))asyncdefon_resumed(self):print("n[LOGS] Bot has resumed session!")asyncdefon_message(self, message):# don't respond to ourselvesif message.author == self.user:returnif message.content =='ping':await ctx.send(f'Client Latency: round(self.bot.latency *1000)')
client = MyClient()
client.run('token')
Ejemplo 2: chat moderado del bot de discordia de Python
import discord
classMyClient(discord.Client):asyncdefon_ready(self):print('Logged on as', self.user)asyncdefon_message(self, message):
word_list =['cheat','cheats','hack','hacks','internal','external','ddos','denial of service']# don't respond to ourselvesif message.author == self.user:return
messageContent = message.content
iflen(messageContent)>0:for word in word_list:if word in messageContent:await message.delete()await message.channel.send('Do not say that!')
messageattachments = message.attachments
iflen(messageattachments)>0:for attachment in messageattachments:if attachment.filename.endswith(".dll"):await message.delete()await message.channel.send("No DLL's allowed!")elif attachment.filename.endswith('.exe'):await message.delete()await message.channel.send("No EXE's allowed!")else:break
client = MyClient()
client.run('token here')
Nos puedes patrocinar nuestra investigación añadiendo un comentario y puntuándolo te damos las gracias.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)