I started using discord.py (not discord.ext commands, only import discord) recently, I made a channel, the name of which shows the member count in the guild, and updates everytime someone joins or leaves. This is my code:
import discord
client = discord.Client()
@client.event
async def on_ready():
print("Bot is ready")
@client.event
async def on_member_join(member):
channel = client.get_channel('channel id here')
await channel.edit(name = 'Member count: {}'.format(channel.guild.member_count()))
@client.event
async def on_member_leave(member):
channel = client.get_channel('channel id here')
await channel.edit(name = 'Member count: {}'.format(channel.guild.member_count()))
client.run('my token here')
I also added "client.on_message" command so the bot would edit that name to whatever I typed in.
@client.event
async def on_message(message)
if message.content == 'rename channel':
channel = client.get_channel('channel id here')
await channel.edit(name = 'TEST')
Now, after adding some print's for debugging, I found out that on_member_join and on_member_leave never get called, but the bot edits the channel's name when I type the command. That's a voice channel, which shows member count. There aren't any errors. Did I read the API wrong? Please help