Skip to content

Commit a3da0fb

Browse files
committed
readme upate, defensive stuff
1 parent 2eea261 commit a3da0fb

3 files changed

Lines changed: 34 additions & 19 deletions

File tree

README.MD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@
110110
4. If the requesting ip is in a state that requires age verification, some of these checkers wont work.
111111

112112
### Update History
113-
- 8/6/2025
113+
- 8/7/2025
114114
- .env file now used instead of AppConstants
115115
- .envExample included to show what vars .env can have
116116
- Moved bot token from secrets/token to .env SECRET var
117+
- This will allow future updates where things won't break on update if new vars are added
118+
- This also means the vars can be changed via docker environment vars as well
117119
- Lots of new features below. Check .envExample for new vars for them
118120
- Whitelisted commands renamed into groups
119121
- commands that require whitelist permission are now under zmod and ymod

plugins/commands.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
import globals
2020
import itertools
2121
import miru
22+
import logging
2223

2324
baseSettings = Settings()
2425
component = tanjun.Component()
2526
moderationGroup = tanjun.slash_command_group("zmod", "commands only moderators can use").add_check(StaticMethods.isPermission)
2627
moderationGroupY = tanjun.slash_command_group("ymod", "commands only moderators can use").add_check(StaticMethods.isPermission )
28+
logger = logging.getLogger(__name__)
29+
logger.setLevel(baseSettings.SASSBOT_LOG_LEVEL)
2730

2831
@tanjun.with_str_slash_option("prefix", "prefix of the emote you want to check")
2932
@tanjun.with_int_slash_option("days", "number of days to look back", default=30)
@@ -211,12 +214,16 @@ async def ConnectKickAccount(ctx: miru.ViewContext) -> None:
211214

212215
@CommandLogger
213216
async def BanAppeal(ctx: miru.ViewContext) -> None:
214-
view = MiruViews.AppealModalView(autodefer=False)
215-
await ctx.respond("Pre-type your ban appeal and then hit the submit button when you are ready to submit it.\n Button will time out after a few mins, so re-push button if it doesn't work", components=view, flags=hikari.MessageFlag.EPHEMERAL)
216-
message = await ctx.get_last_response()
217-
await view.start(message)
218-
await view.wait()
219-
await ctx.interaction.delete_initial_response()
217+
if baseSettings.MOD_ROLE_ID and baseSettings.APPEAL_CHANNEL_ID:
218+
view = MiruViews.AppealModalView(autodefer=False)
219+
await ctx.respond("Pre-type your ban appeal and then hit the submit button when you are ready to submit it.\n Button will time out after a few mins, so re-push button if it doesn't work", components=view, flags=hikari.MessageFlag.EPHEMERAL)
220+
message = await ctx.get_last_response()
221+
await view.start(message)
222+
await view.wait()
223+
await ctx.interaction.delete_initial_response()
224+
else:
225+
await ctx.respond("Can't do that. Command isn't set up correctly. Tell an admin/mod", flags=hikari.MessageFlag.EPHEMERAL)
226+
logger.warning("BanAppeal can't be used. MOD_ROLE_ID and APPEAL_CHANNEL_ID not set")
220227

221228
@moderationGroupY.as_sub_command("appeal-review", "View appeals that need to be reviewd for approval or denial",default_to_ephemeral= True, always_defer= True)
222229
@CommandLogger
@@ -280,17 +287,23 @@ async def confessReview(ctx: tanjun.abc.SlashContext, rest: alluka.Injected[hika
280287
@component.with_slash_command
281288
@tanjun.as_slash_command("confess", "Anonymously post a confession or question to the confessions channel.", always_defer= True, default_to_ephemeral= True)
282289
async def confess(ctx: tanjun.abc.SlashContext) -> None:
283-
content = "Pre-type your Confession/Question and then hit the submit button when you are ready to submit it.\n Button will time out after a few mins, so re-type command if it doesn't work"
284-
view = MiruViews.ConfessionModalView(autodefer=False)
285-
if isinstance(ctx, tanjun.abc.SlashContext):
286-
await ctx.respond(content=content, components=view)
290+
if baseSettings.CONFESSTION_CHANNEL_ID:
291+
content = "Pre-type your Confession/Question and then hit the submit button when you are ready to submit it.\n Button will time out after a few mins, so re-type command if it doesn't work"
292+
view = MiruViews.ConfessionModalView(autodefer=False)
293+
if isinstance(ctx, tanjun.abc.SlashContext):
294+
await ctx.respond(content=content, components=view)
295+
else:
296+
await ctx.respond(content=content, components=view, flags = hikari.MessageFlag.EPHEMERAL)
297+
message = await ctx.fetch_last_response() if isinstance(ctx, tanjun.abc.SlashContext) else await ctx.get_last_response()
298+
await view.start(message)
299+
await view.wait()
300+
await ctx.interaction.delete_initial_response()
287301
else:
288-
await ctx.respond(content=content, components=view, flags = hikari.MessageFlag.EPHEMERAL)
289-
message = await ctx.fetch_last_response() if isinstance(ctx, tanjun.abc.SlashContext) else await ctx.get_last_response()
290-
await view.start(message)
291-
await view.wait()
292-
await ctx.interaction.delete_initial_response()
293-
302+
logger.warning("CONFESS can't be uesed. CONFESSION_CHANNEL_ID not yet")
303+
if isinstance(ctx, tanjun.abc.SlashContext):
304+
await ctx.respond("Can't do that. Command isn't set up correctly. Tell admin/mod")
305+
else:
306+
await ctx.respond("Can't do that. Command isn't set up correctly. Tell admin/mod", flags = hikari.MessageFlag.EPHEMERAL)
294307
@tanjun.with_bool_slash_option("rerunannounce","True if you want rerun pings False if not")
295308
@moderationGroup.as_sub_command("announce-rerun-toggle", "Toggle whether or not the bot will announce reruns", default_to_ephemeral=True, always_defer=True)
296309
@CommandLogger

utils/KickDataGrabber.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ async def AnnounceWinnersHandleData(kickSlug: str, rest:hikari.impl.RESTClientIm
8989
f"- ** {mostViewsTitle.capitalize()} ** with ** {mostViews} ** views gained\n" \
9090
f" - clipped by: ** {mostViewsClipper.capitalize()} ** \n"\
9191
f" - ** {mostViewedClipUrl} **"
92-
if userViews and mostViewedUser and mostClipper and numClips and mostViewsTitle and mostViewsClipId:
92+
if userViews and mostViewedUser and mostClipper and numClips and mostViewsTitle and mostViewsClipId and baseSettings.KICK_CLIPS_ANNOUNCEMENT_CHANNEL:
9393
await rest.create_message(channel=baseSettings.KICK_CLIPS_ANNOUNCEMENT_CHANNEL, content=messageContent)
9494
else:
95-
logger.warning("Weekly Kick Clip Data announcement cancelled. Data gathering interrupted or no data")
95+
logger.warning("Weekly Kick Clip Data announcement cancelled. Data gathering interrupted, no data, or announcement channel not set")
9696
db.createWeeklyKickClipsData(f"{isoYear}:{isoWeek}",mostViewsClipId, mostViewedUser, mostClipper)
9797

9898
async def connectKickWebSockets():

0 commit comments

Comments
 (0)