Reputation: 35
I wanna make a way so that a bot can check a user's status when they type a message and give them a role if their status contains specific words. This is my code atm, yes I've enabled priviliged intents and I'm starting the loop command in the on_message event. The thing is that it returns "ctx is a positional argument that is missing :/ now how do I fix that?
@tasks.loop()
async def check(ctx):
supporter = discord.utils.get(ctx.guild.roles, name="Supporter")
member = ctx.author
if ".gg/eternalgw" in member.activity:
await ctx.send(f"I gave {member.mention} the Supporter role for supporting us!")
await member.add_role(supporter)```
Upvotes: 0
Views: 85
Reputation: 1415
tasks.loop
do not take ctx
as an argument, because it doesn't make any sense. If you really want to check status with a loop you have to check all members of the guild. But if you just want to execute this code when someone sends a message use the on_message
event:
@bot.event
async def on_message(message):
supporter = discord.utils.get(message.guild.roles, name="Supporter")
member = message.author
if ".gg/eternalgw" in str(member.activity):
await message.channel.send(f"I gave {member.mention} the Supporter role for supporting us!")
await member.add_roles(supporter)
Upvotes: 1