problema con ids
Some checks failed
Update Bot / restart-bot (push) Has been cancelled
Update Bot / deploy-via-sftp (push) Has been cancelled

This commit is contained in:
2025-10-27 09:35:02 +01:00
parent 767874c246
commit d31540514a

12
main.py Normal file → Executable file
View File

@@ -2,7 +2,7 @@ import requests
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord.ext import tasks from discord.ext import tasks
import secrets import os
import time import time
import xmltodict import xmltodict
@@ -32,7 +32,7 @@ async def on_ready():
async def send_log(msg): #Mandar log async def send_log(msg): #Mandar log
channel = bot.get_channel(secrets.IDcanalLogs) #Canal al que se envía el log channel = bot.get_channel(int(os.environ["IDcanalLogs"])) #Canal al que se envía el log
await channel.send(msg) await channel.send(msg)
@@ -41,7 +41,7 @@ async def mandar_noticia():
global ultimaurl global ultimaurl
try: try:
channel = bot.get_channel(secrets.IDcanalNoticias) #Canal al que se envía el mensaje channel = bot.get_channel(int(os.environ["IDcanalNoticias"])) #Canal al que se envía el mensaje
r = requests.get(url) r = requests.get(url)
xml = xmltodict.parse(r.text) xml = xmltodict.parse(r.text)
@@ -54,7 +54,7 @@ async def mandar_noticia():
nuevas.append(loc) nuevas.append(loc)
if nuevas: #Si el array no está vacío if nuevas: #Si el array no está vacío
await channel.send(f"Atención <@&{secrets.IDrol}> hay nuevas noticias:") #Luego hay que cambiar el rol await channel.send(f"Atención <@&{int(os.environ['IDRol'])}> hay nuevas noticias:") #Luego hay que cambiar el rol
for loc in reversed(nuevas): #Recorre el array hacia atrás para mandarlas en orden. for loc in reversed(nuevas): #Recorre el array hacia atrás para mandarlas en orden.
await channel.send(f"\n{loc}") await channel.send(f"\n{loc}")
ultimaurl = urls[0] #Actualizamos la url vieja ultimaurl = urls[0] #Actualizamos la url vieja
@@ -64,7 +64,7 @@ async def mandar_noticia():
@bot.command() @bot.command()
async def noticias(ctx): async def noticias(ctx):
rol = ctx.guild.get_role(secrets.IDrol) rol = ctx.guild.get_role(int(os.environ["IDRol"]))
user = ctx.author user = ctx.author
if rol in user.roles: if rol in user.roles:
@@ -97,4 +97,4 @@ async def noticias(ctx):
if __name__ == '__main__': if __name__ == '__main__':
bot.run(secrets.TOKEN) bot.run(os.environ["TOKEN"])