I'm very new to using discord.py and python in general so please bear with me.
My current goal is to make my discord bot send a welcome and a leave message to a certain channel when a person joins or leaves. In that message I would like to include both the person's name and the name of the server, guild, being joined, or left.
The code I have so far is:
@client.event
async def on_member_join(member):
print(f'Greetings {member}, welcome to server')
I know that this only prints the message in the terminal. I don't know how to make the bot send a message to a text channel. I do know that you can use .send, however, I don't know which object to use before it, channel, ctx, etc.
I also have confusion in regards to collecting the server name. I've tried using discord.Guild.name but that only returns <member 'name' of 'Guild' objects>.
I have tried looking through the documentation to fix my problem but either I'm blind and can't find the solution or too dumb to realize the solution when I see it.
Please point me in the right direction to solving my issue or provide the correct code I should use, anything constructive and helpful is greatly appreciated and desired.
Thanks for reading this post and potentially aiding me.
Best regards, Kelsier
EDIT:
The main issue that I have been running into is the fact that you need a message parameter and then have a message be sent in chat to then have the bot react and send a message. This is troublesome because in the on_member_join and on_member_remove events the only parameter is member, removing the possibility, at least I think so, to define and then send a message.
From reading the documents there doesn't seem to be an easy print-statement like function that simply sends a message, which is very annoying.