Añadida otra lista de defectos
This commit is contained in:
77
main.py
77
main.py
@@ -2,22 +2,20 @@ import discord
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from threading import Thread
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
intents = discord.Intents.all()
|
intents = discord.Intents.all()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
|
|
||||||
|
|
||||||
bot = discord.Bot(intents=intents)
|
bot = discord.Bot(intents=intents)
|
||||||
NL = "\n"
|
NL = "\n"
|
||||||
PREFIX = "f!"
|
PREFIX = "f!"
|
||||||
|
|
||||||
cmds = []
|
cmds = []
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f"Bot vivo! \nUsuario: {bot.user}")
|
print(f"Bot vivo! \nUsuario: {bot.user}")
|
||||||
@@ -32,6 +30,7 @@ async def on_ready():
|
|||||||
print(f"características actuales: {msg.content}")
|
print(f"características actuales: {msg.content}")
|
||||||
await send_log(f"hora de inicio: {time.ctime(time.time())}")
|
await send_log(f"hora de inicio: {time.ctime(time.time())}")
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
@@ -42,43 +41,44 @@ async def on_message(message):
|
|||||||
if message.content.startswith(f'{PREFIX}helpme'):
|
if message.content.startswith(f'{PREFIX}helpme'):
|
||||||
await message.channel.send(make_help())
|
await message.channel.send(make_help())
|
||||||
|
|
||||||
|
|
||||||
@bot.command(description="Añade una característica más de Arnau!")
|
@bot.command(description="Añade una característica más de Arnau!")
|
||||||
async def add(ctx, attr: discord.Option(str)):
|
async def add(ctx, attr: str, user: str):
|
||||||
channel = bot.get_channel(1153429735527948399)
|
if user == "Juan":
|
||||||
msg = await channel.fetch_message(1153429808429158460)
|
channel = bot.get_channel(1166495380003889232)
|
||||||
if attr.lower() not in msg.content.lower():
|
elif user == "Arnau":
|
||||||
await msg.edit(content = f'{msg.content}\n- {attr}')
|
channel = bot.get_channel(1153429735527948399)
|
||||||
await ctx.respond(f"Característica añadida! ", ephemeral=True)
|
if attr.lower() not in msg.content.lower():
|
||||||
await send_log(f"Característica añadida: {attr} por {ctx.user}")
|
await channel.send(f'- {attr}')
|
||||||
|
await ctx.respond(f"Característica añadida! ", ephemeral=True)
|
||||||
|
await send_log(f"Característica añadida: {attr} por {ctx.user}")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
await ctx.respond("Característica ya añadida!", ephemeral=True)
|
await ctx.respond("Característica ya añadida!", ephemeral=True)
|
||||||
|
|
||||||
@bot.command(description = "Borrar una característica de Arnau (sólo admins)")
|
|
||||||
|
@bot.command(description="Borrar una característica de Arnau (sólo admins)")
|
||||||
async def delete(ctx, attr: discord.Option(str)):
|
async def delete(ctx, attr: discord.Option(str)):
|
||||||
channel = bot.get_channel(1153429735527948399)
|
channel = bot.get_channel(1153429735527948399)
|
||||||
msg = await channel.fetch_message(1153429808429158460)
|
msg = await channel.fetch_message(1153429808429158460)
|
||||||
role = discord.utils.get(ctx.guild.roles, name = "Admin")
|
role = discord.utils.get(ctx.guild.roles, name="Admin")
|
||||||
if role not in ctx.author.roles or ctx.author.id == 676816739065004043:
|
if role not in ctx.author.roles or ctx.author.id == 676816739065004043:
|
||||||
await ctx.respond("No tienes permiso para hacerlo!", ephemeral = True)
|
await ctx.respond("No tienes permiso para hacerlo!", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
if attr.lower() not in msg.content.lower():
|
if attr.lower() not in msg.content.lower():
|
||||||
await ctx.respond("Característica no encontrada.", ephemeral = True)
|
await ctx.respond("Característica no encontrada.", ephemeral=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
await msg.edit(content = f'{msg.content.replace(f"{NL}- {attr}", "")}')
|
await msg.edit(content=f'{msg.content.replace(f"{NL}- {attr}", "")}')
|
||||||
await ctx.respond("Característica eliminada :(", ephemeral = True)
|
await ctx.respond("Característica eliminada :(", ephemeral=True)
|
||||||
await send_log(f"Característica eliminada: {attr} por {ctx.user}")
|
await send_log(f"Característica eliminada: {attr} por {ctx.user}")
|
||||||
|
|
||||||
|
|
||||||
async def send_log(msg):
|
async def send_log(msg):
|
||||||
channel = bot.get_channel(1153800096761262152)
|
channel = bot.get_channel(1153800096761262152)
|
||||||
msg = await channel.send(msg)
|
await channel.send(msg)
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
def startpage():
|
|
||||||
return "<img src='https://www.banderasphonline.com/wp-content/uploads/2020/03/bandera-espa%C3%B1a-con-escudo-para-exterior-interior-1200x675.png'></img>"
|
|
||||||
|
|
||||||
def parse_cmds(f):
|
def parse_cmds(f):
|
||||||
cmd_file = open(f)
|
cmd_file = open(f)
|
||||||
@@ -89,6 +89,7 @@ def parse_cmds(f):
|
|||||||
links = [_ for _ in line.split()[1:]]
|
links = [_ for _ in line.split()[1:]]
|
||||||
cmds.append((cmd, links))
|
cmds.append((cmd, links))
|
||||||
|
|
||||||
|
|
||||||
def make_help():
|
def make_help():
|
||||||
help = ("helpme", f"""El prefijo de este bot es: f!
|
help = ("helpme", f"""El prefijo de este bot es: f!
|
||||||
|
|
||||||
@@ -100,20 +101,8 @@ Disfrutad del bot
|
|||||||
""")
|
""")
|
||||||
return help[1]
|
return help[1]
|
||||||
|
|
||||||
def runServer():
|
|
||||||
app.run(host='0.0.0.0', port=8181)
|
|
||||||
|
|
||||||
def keep_alive():
|
if __name__ == '__main__':
|
||||||
t = Thread(target=runServer)
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
def run():
|
|
||||||
keep_alive()
|
|
||||||
parse_cmds("cmds.txt")
|
parse_cmds("cmds.txt")
|
||||||
make_help()
|
make_help()
|
||||||
try:
|
bot.run(os.environ['TOKEN'])
|
||||||
return bot.run(os.environ['TOKEN'])
|
|
||||||
except:
|
|
||||||
return os.system("kill 1") # sinceramente, no sé por qué funciona ni si realmente funciona así, pero funciona
|
|
||||||
|
|
||||||
run()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user