Discord Channel is not being recognized when using get_channel
I'm trying to make a discord bot that sends a message in a different channel, every time someone joins the server. The bot is recognizing that someone joined but it does not recognize the channel and therefore won't send a message. The channel returns as none when I try to print it, to see if it's being recognized.
intents = discord.Intents(members=True)
client=discord.Client(intents=intents)
@client.event
async def on_member_join(member):
await client.wait_until_ready()
channel = client.get_channel(id)
print(channel)
print("Recognised that a member called " + member.name + " joined")
await channel.message.send('Hello' + member.name)
You need to enable guilds intent to use get_channel
method.
intents = discord.Intents(members=True, guilds=True)
client=discord.Client(intents=intents)