Skip to content

Commit

Permalink
Merge branch 'main' into implement-strike-message
Browse files Browse the repository at this point in the history
  • Loading branch information
MattyTheHacker committed Sep 25, 2024
2 parents ee2e8d0 + d9643af commit d6c29d1
Show file tree
Hide file tree
Showing 15 changed files with 511 additions and 467 deletions.
40 changes: 20 additions & 20 deletions cogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@
from collections.abc import Sequence

__all__: Sequence[str] = (
"AnnualRolesResetCommandCog",
"AnnualYearChannelsIncrementCommandCog",
"ArchiveCommandCog",
"GetTokenAuthorisationCommandCog",
"ClearRemindersBacklogTaskCog",
"CommandErrorCog",
"CommitteeHandoverCommandCog",
"DeleteAllCommandsCog",
"EditMessageCommandCog",
"EnsureMembersInductedCommandCog",
"MakeApplicantSlashCommandCog",
"MakeApplicantContextCommandsCog",
"CommitteeHandoverCommandCog",
"AnnualRolesResetCommandCog",
"InductSlashCommandCog",
"InductSendMessageCog",
"GetTokenAuthorisationCommandCog",
"InductContextCommandsCog",
"InductSendMessageCog",
"InductSlashCommandCog",
"KillCommandCog",
"MakeApplicantContextCommandsCog",
"MakeApplicantSlashCommandCog",
"MakeMemberCommandCog",
"AnnualYearChannelsIncrementCommandCog",
"ManualModerationCog",
"PingCommandCog",
"ClearRemindersBacklogTaskCog",
"RemindMeCommandCog",
"SendGetRolesRemindersTaskCog",
"SendIntroductionRemindersTaskCog",
"setup",
"SourceCommandCog",
"StartupCog",
"StatsCommandsCog",
"ManualModerationCog",
"StrikeCommandCog",
"StrikeContextCommandsCog",
"WriteRolesCommandCog",
"setup",
)


Expand Down Expand Up @@ -82,31 +82,31 @@
def setup(bot: TeXBot) -> None:
"""Add all the cogs to the bot, at bot startup."""
cogs: Iterable[type[TeXBotBaseCog]] = (
AnnualRolesResetCommandCog,
AnnualYearChannelsIncrementCommandCog,
ArchiveCommandCog,
GetTokenAuthorisationCommandCog,
ClearRemindersBacklogTaskCog,
CommandErrorCog,
CommitteeHandoverCommandCog,
DeleteAllCommandsCog,
EditMessageCommandCog,
EnsureMembersInductedCommandCog,
CommitteeHandoverCommandCog,
AnnualRolesResetCommandCog,
InductSlashCommandCog,
InductSendMessageCog,
AnnualYearChannelsIncrementCommandCog,
GetTokenAuthorisationCommandCog,
InductContextCommandsCog,
InductSendMessageCog,
InductSlashCommandCog,
KillCommandCog,
MakeApplicantSlashCommandCog,
MakeApplicantContextCommandsCog,
MakeApplicantSlashCommandCog,
MakeMemberCommandCog,
ManualModerationCog,
PingCommandCog,
ClearRemindersBacklogTaskCog,
RemindMeCommandCog,
SendGetRolesRemindersTaskCog,
SendIntroductionRemindersTaskCog,
SourceCommandCog,
StartupCog,
StatsCommandsCog,
ManualModerationCog,
StrikeCommandCog,
StrikeContextCommandsCog,
WriteRolesCommandCog,
Expand Down
2 changes: 1 addition & 1 deletion cogs/annual_handover_and_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from collections.abc import Sequence

__all__: Sequence[str] = (
"CommitteeHandoverCommandCog",
"AnnualRolesResetCommandCog",
"AnnualYearChannelsIncrementCommandCog",
"CommitteeHandoverCommandCog",
)

import datetime
Expand Down
29 changes: 10 additions & 19 deletions cogs/induct.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from collections.abc import Sequence

__all__: Sequence[str] = (
"InductSendMessageCog",
"BaseInductCog",
"InductSlashCommandCog",
"InductContextCommandsCog",
"EnsureMembersInductedCommandCog",
"InductContextCommandsCog",
"InductSendMessageCog",
"InductSlashCommandCog",
)


Expand Down Expand Up @@ -185,6 +185,8 @@ async def _perform_induction(self, ctx: TeXBotApplicationContext, induction_memb
main_guild: discord.Guild = self.bot.main_guild
guest_role: discord.Role = await self.bot.guest_role

logger.debug("Inducting member %s, silent=%s", induction_member, silent)

INDUCT_AUDIT_MESSAGE: Final[str] = (
f"{ctx.user} used TeX Bot slash-command: \"/induct\""
)
Expand Down Expand Up @@ -223,22 +225,11 @@ async def _perform_induction(self, ctx: TeXBotApplicationContext, induction_memb
with contextlib.suppress(RolesChannelDoesNotExistError):
roles_channel_mention = (await self.bot.roles_channel).mention

message_already_sent: bool = False
message: discord.Message
async for message in general_channel.history(limit=7):
message_already_sent = bool(
message.author == self.bot.user
and "grab your roles" in message.content # noqa: COM812
)
if message_already_sent:
break

if not message_already_sent:
await general_channel.send(
f"{await self.get_random_welcome_message(induction_member)} :tada:\n"
f"Remember to grab your roles in {roles_channel_mention} "
"and say hello to everyone here! :wave:",
)
await general_channel.send(
f"{await self.get_random_welcome_message(induction_member)} :tada:\n"
f"Remember to grab your roles in {roles_channel_mention} "
"and say hello to everyone here! :wave:",
)

await induction_member.add_roles(
guest_role,
Expand Down
2 changes: 1 addition & 1 deletion cogs/kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections.abc import Sequence

__all__: Sequence[str] = ("KillCommandCog", "ConfirmKillView")
__all__: Sequence[str] = ("ConfirmKillView", "KillCommandCog")


import contextlib
Expand Down
2 changes: 1 addition & 1 deletion cogs/make_applicant.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

__all__: Sequence[str] = (
"BaseMakeApplicantCog",
"MakeApplicantSlashCommandCog",
"MakeApplicantContextCommandsCog",
"MakeApplicantSlashCommandCog",
)


Expand Down
2 changes: 1 addition & 1 deletion cogs/remind_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections.abc import Sequence

__all__: Sequence[str] = ("RemindMeCommandCog", "ClearRemindersBacklogTaskCog")
__all__: Sequence[str] = ("ClearRemindersBacklogTaskCog", "RemindMeCommandCog")


import datetime
Expand Down
6 changes: 3 additions & 3 deletions cogs/strike.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from collections.abc import Sequence

__all__: Sequence[str] = (
"perform_moderation_action",
"ConfirmStrikeMemberView",
"BaseStrikeCog",
"ConfirmManualModerationView",
"ConfirmStrikeMemberView",
"ConfirmStrikesOutOfSyncWithBanView",
"BaseStrikeCog",
"ManualModerationCog",
"perform_moderation_action",
"StrikeCommandCog",
"StrikeContextCommandsCog",
)
Expand Down
16 changes: 8 additions & 8 deletions exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
"ChannelDoesNotExistError",
"CommitteeElectRoleDoesNotExistError",
"CommitteeRoleDoesNotExistError",
"DiscordMemberNotInMainGuildError",
"EveryoneRoleCouldNotBeRetrievedError",
"GeneralChannelDoesNotExistError",
"GuestRoleDoesNotExistError",
"GuildDoesNotExistError",
"ImproperlyConfiguredError",
"InvalidMessagesJSONFileError",
"MemberRoleDoesNotExistError",
"MessagesJSONFileMissingKeyError",
"MessagesJSONFileValueError",
"NoAuditLogsStrikeTrackingError",
"RestartRequiredDueToConfigChange",
"RoleDoesNotExistError",
"RolesChannelDoesNotExistError",
"RulesChannelDoesNotExistError",
"DiscordMemberNotInMainGuildError",
"EveryoneRoleCouldNotBeRetrievedError",
"StrikeTrackingError",
"NoAuditLogsStrikeTrackingError",
"MessagesJSONFileMissingKeyError",
"MessagesJSONFileValueError",
"InvalidMessagesJSONFileError",
"ImproperlyConfiguredError",
"RestartRequiredDueToConfigChange",
)


Expand Down
16 changes: 8 additions & 8 deletions exceptions/does_not_exist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
from collections.abc import Sequence

__all__: Sequence[str] = (
"RulesChannelDoesNotExistError",
"GuildDoesNotExistError",
"RoleDoesNotExistError",
"CommitteeRoleDoesNotExistError",
"ApplicantRoleDoesNotExistError",
"ArchivistRoleDoesNotExistError",
"ChannelDoesNotExistError",
"CommitteeElectRoleDoesNotExistError",
"CommitteeRoleDoesNotExistError",
"GeneralChannelDoesNotExistError",
"GuestRoleDoesNotExistError",
"GuildDoesNotExistError",
"MemberRoleDoesNotExistError",
"ArchivistRoleDoesNotExistError",
"ApplicantRoleDoesNotExistError",
"ChannelDoesNotExistError",
"RoleDoesNotExistError",
"RolesChannelDoesNotExistError",
"GeneralChannelDoesNotExistError",
"RulesChannelDoesNotExistError",
)


Expand Down
2 changes: 1 addition & 1 deletion exceptions/strike.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from collections.abc import Sequence

__all__: Sequence[str] = (
"StrikeTrackingError",
"NoAuditLogsStrikeTrackingError",
"StrikeTrackingError",
)


Expand Down
Loading

0 comments on commit d6c29d1

Please sign in to comment.