Skip to content

Commit

Permalink
Merge pull request #127 from kelvin-codes-stuff:Welcome-message-general
Browse files Browse the repository at this point in the history
Toegevoegd: Welkoms bericht auto verwijdering en tekst optimalisatie
  • Loading branch information
AeroBytesNL authored Jan 17, 2024
2 parents 5373427 + 17561d0 commit d3eb462
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cogs/welcome_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def __init__(self, bot: commands.Bot):
self.bot = bot
print("Cog Welcome_message is loaded!")
self.joined_members = []
self.potential_messages_deletion = {}


@commands.Cog.listener()
Expand All @@ -27,9 +28,20 @@ async def on_member_update(self, before, after):

general_channel = await self.bot.fetch_channel(Channel.GENERAL)
joined_user = await self.bot.get_or_fetch_user(before.id)
bot_user = await self.bot.get_or_fetch_user(self.bot.user.id)

await general_channel.send(f"Welkom {joined_user.mention} in All Day Tech & Gaming.\n\nIn onze server maken we gebruik van verschillende kanalen om onderwerpen gescheiden te houden:\n- Hulp nodig met tech? <#1019678705045471272>\n- Voor tech gesprekken zie <#723556858820034612>\n- Voor game gesprekken zie <#759456512165937183>\nMocht je vragen hebben m.b.t het beheer dan kun je {bot_user.mention} DM'en!")
welcome_message = await general_channel.send(f"Welkom {joined_user.mention} in All Day Tech & Gaming!\n\nIn onze server maken we gebruik van verschillende kanalen om onderwerpen gescheiden te houden:\n- Ben je opzoek naar hulp, dan kan je in <#1019678705045471272> een forum bericht starten.\n- Babbelen over alles wat met tech te maken heeft? <#723556858820034612>\n- Gesprekken met betrekking tot games? <#759456512165937183>\nMocht je vragen hebben m.b.t. het beheer dan kun je {self.bot.user.mention} DM'en!")
self.potential_messages_deletion.update({before.id:welcome_message.id})


@commands.Cog.listener()
async def on_member_remove(self, member):
try:
message_to_delete = self.bot.get_message(int(self.potential_messages_deletion[member.id]))
await message_to_delete.delete()
self.potential_messages_deletion.pop(member.id)
except Exception as error:
print("Error inside welcome_message: ", error)
pass


def setup(bot: commands.Bot):
Expand Down

0 comments on commit d3eb462

Please sign in to comment.