Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions amulet_discord_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ async def _log(self, msg: str) -> None:

async def on_ready(self) -> None:
try:
await self._log(f"I am {os.getlogin()} and I am back")
msg = f"I am {os.getlogin()} and I am back"
except:
await self._log("I am back")
msg = "I am back"
await self._log(msg)

async def ban(self, member: discord.Member, reason: str = "Undefined") -> None:
"""Ban a user from the server"""
Expand Down Expand Up @@ -65,11 +66,11 @@ async def _remove_and_dm(self, message: discord.Message, dm_str: str) -> None:
f"Message removed from {author.name} in {channel_name}. The warning sent to the user is as follows.\n"
f"{dm_message}"
)
await message.delete()
try:
await author.send(dm_message)
except:
pass
await message.delete()
except discord.errors.Forbidden:
await self._log(f"Unable to send message to {author.name}.")

@staticmethod
def has_link(msg: str) -> bool:
Expand Down Expand Up @@ -177,9 +178,10 @@ async def _process_message(self, message: discord.Message) -> None:
elif channel_id == Chats.ServerLog and message_text == "!ping":
# alive check
try:
await self._log(f"Pong! {os.getlogin()}")
msg = f"Pong! {os.getlogin()}"
except:
await self._log(f"Pong!")
msg = f"Pong!"
await self._log(msg)
return

if (
Expand Down Expand Up @@ -244,5 +246,6 @@ def main() -> None:

intents = discord.Intents.default()
intents.members = True
intents.message_content = True
client = AmuletBot(intents=intents)
client.run(args.bot_token)