mirror of
https://github.com/insertapp/mmolbbot.git
synced 2025-08-01 10:43:34 +00:00
chore: use env for error channel
This commit is contained in:
parent
c138a608d6
commit
fa60c9b78d
3 changed files with 24 additions and 21 deletions
|
@ -4,5 +4,6 @@ The bot is user-installable so the commands can either be added to a guild or yo
|
|||
Invite: https://discord.com/oauth2/authorize?client_id=1365149865444905121
|
||||
# Building
|
||||
inside the folder
|
||||
`docker build . -t mmolbbot`
|
||||
`docker run mmolbbot -e TOKEN=<Token> -e OWNER_GUILD=<guild with management commands>`
|
||||
`docker build -t mmolbbot .`
|
||||
# Hosting
|
||||
`docker run -e TOKEN=<Token> -e OWNER_GUILD=<guild with management commands> -e ERROR_CHANNEL=<error channel id> -e DB_PATH="./mmolb.db" mmolbbot`
|
6
bot.py
6
bot.py
|
@ -63,6 +63,7 @@ async def on_ready():
|
|||
await db.commit()
|
||||
bot.db = db
|
||||
bot.cur = cur
|
||||
bot.error_channel = int(os.getenv("ERROR_CHANNEL"))
|
||||
guild_list = []
|
||||
async for guild in bot.fetch_guilds():
|
||||
guild_list.append(guild.id)
|
||||
|
@ -115,14 +116,15 @@ cog: str = SlashOption(required=False)
|
|||
)
|
||||
@application_checks.is_owner()
|
||||
async def delliveupdates(interaction: nextcord.Interaction,
|
||||
confirm: str = SlashOption(required=False)
|
||||
confirm: str = SlashOption(required=False),
|
||||
classic: int = SlashOption(required=False)
|
||||
):
|
||||
if confirm == "yes, do as I say!":
|
||||
await db.execute(f"""DELETE from liveupdate""")
|
||||
await db.commit()
|
||||
await interaction.response.send_message("all gone...")
|
||||
else:
|
||||
res = await db.execute("SELECT COUNT (*) from liveupdate")
|
||||
res = await db.execute("SELECT COUNT (*) from liveupdate WHERE classic = ?",(classic,))
|
||||
res, = await res.fetchone()
|
||||
await interaction.response.send_message(f"There are currently {res} live updates")
|
||||
|
||||
|
|
|
@ -87,10 +87,10 @@ async def livegameworker(self,serverid,userid,channelid,messageid,gameid,offset)
|
|||
#await self.bot.db.commit()
|
||||
if message:
|
||||
await message.edit(f"An error occoured in this live update\n{e}")
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
except nextcord.Forbidden:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await self.bot.db.execute("DELETE from teamsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from liveupdate WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from spotlightsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
|
@ -136,10 +136,10 @@ async def classiclivegameworker(self,serverid,userid,channelid,gameid,offset):
|
|||
UPDATE liveupdate set offset = {offset+offsetadd} WHERE channelid = '{channelid}' AND gameid = '{gameid}' AND classic = 1
|
||||
""")
|
||||
except Exception as e:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
except nextcord.Forbidden:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await self.bot.db.execute("DELETE from teamsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from liveupdate WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from spotlightsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
|
@ -196,10 +196,10 @@ async def statisticallivegameworker(self,serverid,userid,channelid,gameid,offset
|
|||
UPDATE liveupdate set offset = {offset+offsetadd} WHERE channelid = '{channelid}' AND gameid = '{gameid}' AND classic = 2
|
||||
""")
|
||||
except Exception as e:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
except nextcord.Forbidden:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await self.bot.db.execute("DELETE from teamsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from liveupdate WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from spotlightsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
|
@ -235,10 +235,10 @@ async def spotlightsubscriptionworker(self,serverid,channelid,classic,gameid,dat
|
|||
await self.bot.db.close()
|
||||
self.checkspotlightsubscriptions.cancel()
|
||||
self.checkteamsubscriptions.cancel()
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(f"<@{self.bot.owner_id}> database is locked!")
|
||||
except Exception as e:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(f"Ignoring exception in spotlight check: {e}")
|
||||
print(e)
|
||||
return
|
||||
|
@ -286,10 +286,10 @@ async def teamsubscriptionworker(self,serverid,channelid,teamid,classic):
|
|||
await self.bot.db.close()
|
||||
self.checkspotlightsubscriptions.cancel()
|
||||
self.checkteamsubscriptions.cancel()
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(f"<@{self.bot.owner_id}> database is locked!")
|
||||
except Exception as e:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(f"Ignoring exception in {teamid}: {e}")
|
||||
print(e)
|
||||
return
|
||||
|
@ -314,10 +314,10 @@ async def feedsubscriptionworker(self,serverid,channelid,teamid,offset):
|
|||
""")
|
||||
await channel.send(finalstr)
|
||||
except Exception as e:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
except nextcord.Forbidden:
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await self.bot.db.execute("DELETE from teamsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from liveupdate WHERE serverid = ?", (lastserverid,))
|
||||
await self.bot.db.execute("DELETE from spotlightsubscriptions WHERE serverid = ?", (lastserverid,))
|
||||
|
@ -685,7 +685,7 @@ class liveupdate(commands.Cog):
|
|||
|
||||
@tasks.loop(seconds=30.0)
|
||||
async def updatelivegames(self):
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
try:
|
||||
begin = timeit.default_timer()
|
||||
await self.bot.wait_until_ready()
|
||||
|
@ -715,7 +715,7 @@ class liveupdate(commands.Cog):
|
|||
await warning.send(finalstr)
|
||||
timings.clear()
|
||||
except Exception as e:
|
||||
#warning = self.bot.get_channel(1365478368555827270)
|
||||
#warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
print(e)
|
||||
|
||||
|
@ -749,7 +749,7 @@ class liveupdate(commands.Cog):
|
|||
except Exception as e:
|
||||
#I know this is bad practice but these loops must be running
|
||||
print(e)
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
return
|
||||
|
||||
|
@ -765,7 +765,7 @@ class liveupdate(commands.Cog):
|
|||
await self.bot.db.commit()
|
||||
except Exception as e:
|
||||
#I know this is bad practice but these loops must be running
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
print(e)
|
||||
return
|
||||
|
@ -781,7 +781,7 @@ class liveupdate(commands.Cog):
|
|||
await self.bot.db.commit()
|
||||
except Exception as e:
|
||||
#I know this is bad practice but these loops must be running
|
||||
warning = self.bot.get_channel(1365478368555827270)
|
||||
warning = self.bot.get_channel(self.bot.error_channel)
|
||||
await warning.send(e)
|
||||
print(e)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue