Reputation: 13
I'm still learning python/discord.py and am attempting to build a simple bot to detect changes in a users status (online/offline); shown below is an implementation which should detect all member updates.
from discord.ext import commands
import discord
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="$", intents=intents)
target_channel_id = <id here>
@bot.event
async def on_ready():
print("bot ready")
@bot.event
async def on_member_update(before, after):
channel = bot.get_channel(target_channel_id)
await channel.send("Member updated!")
print("member updated!")
bot.run("<token here>")
I have my intents enabled properly as evidenced by the bot responding to name/role changes, but nothing appears to happen with status changes. Like I said I'm still new to both python and discord.py so I'm not sure if I just don't know something, but in the documentation it says that on_member_update() should be called with status changes, so I'm not sure what the issue is. Thank you for reading!
Upvotes: 1
Views: 1167
Reputation: 436
Enable the below three intents in your code and your code will start working if status update occurs
intents = discord.Intents( guilds=True,members=True,presences=True)
Upvotes: 1