Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toegevoegd: Welkoms bericht auto verwijdering en tekst optimalisatie #127

Merged
merged 1 commit into from
Jan 17, 2024
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
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