Reputation: 37
The program should work in such a way that a channel named "members" will display the number of members on the server, but the program does not give errors and does not work itself. Thanks in advance!
async def on_member_join(member):
guild = member.guild
channel = get(guild.channels, name = 'members')
await channel.edit(name = f'Учатники: {guild.member_count}')
@bot.event
async def on_member_remove(member):
guild = member.guild
channel = get(guild.channels, name = 'members')
await channel.edit(name = f'Учатники: {guild.member_count}')
Upvotes: 1
Views: 4281
Reputation: 36
I am not really sure if you have it in your program but just to be sure, define what is the attribute named "channel" so it knows what to edit, you can use get_channel
to do it and put the channels ID afterward inside it ( https://discordpy.readthedocs.io/en/latest/api.html?highlight=get_channel#discord.Client.get_channel)
Maybe just try and use it the old way and use name = "Учатники: " + str(guild.member_count)
(The member_count
gives you an output of int
so you may need to turn it into a string before displaying it.
(I have not tested anything and this answer is based on experience and reading documents and also you might want to take a look at https://discordpy.readthedocs.io/en/latest/api.html?highlight=member_count#discord.Guild.member_count)
Upvotes: 2