1
votes

i want to make a discord bot which assigns a role called "supporter" to a user whose status message contains a string called "Testing" using discord.py. I am unable to find a way to get the status message contents.

1
Does your bot have the "presence intent" enabled?itzFlubby
Please post the code you are working on. Your question cannot be answered if there is absolutely no idea of what you are doing in your code.Klaassiek

1 Answers

0
votes

In order to achieve what you want, simply iterate over all members via

for member in guild.members:  

where guild is the object of the guild you want to check.
And then get the activities of each member. You will need to check, if the activity is not none.

for member in guild.members: 
    memberActivity = member.activity
    if not (memberActivity is None):
        nameOfActivity = memberActivity.name  

Afterwards you can check if "Testing" is the name of the activity. And if thats the case, assign the role:

for member in guild.members: 
    memberActivity = member.activity
    if not (memberActivity is None):
        nameOfActivity = memberActivity.name 
        if "Testing" in nameOfActivity:
            await member.add_roles(testingRole) 

where testingRole is the object of your testing role.

You will need to have the presence intent for this to work!