I am trying to add the on_member_join() methods, so that I can be notified using my own custom messages when someone joins.
So I have a channel called main-channel on my server, which is where I want those welcome messages to be printed by the bot. However, I'm not sure how to go about doing that. This is currently my setup, but it doesn't work.
The error I get is:
Ignoring exception in on_member_join Traceback (most recent call last): File "C:\Users\frenc\PycharmProjects\Discord\discord\client.py", line 255, in _run_event await coro(*args, **kwargs) File "C:/Users/frenc/PycharmProjects/Discord/prova.py", line 18, in on_member_join await channel.send("Benvenuto nel Server!") TypeError: can't send non-None value to a just-started coroutine C:\Users\frenc\PycharmProjects\Discord\discord\client.py:262: RuntimeWarning: coroutine 'Member._get_channel' was never awaited pass
I don't really have any idea on how to make my bot print these messages to that specific channel on my server.
I use the latest version of discord and Python 3.6.
import discord
client = discord.Client()
@client.event
async def on_ready():
print('logged in as')
print(client.user.name)
print(client.user.id)
print('-----')
@client.event
async def on_member_join(member):
print("Recognised that a member called " + member.name + " joined")
channel = member._get_channel()
await channel.send("Welcome to the server!")
print("Sent message to " + member.name)
role = discord.utils.get(member.server.roles, name="@everyone")
await member.add_roles(member, role)
print("Added role '" + role.name + "' to " + member.name)
client.run(myToken)