Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Why aren't my member variables filled when I use discord.utils.get()?

$
0
0

The ID-s are the correct 18 number ones from discord, the intents and bot rights are set properly, yet both fetches come back with None.

import discordfrom discord.ext import commandsintents = discord.Intents.default()intents.members = Truebot = commands.Bot(command_prefix='!', intents=intents)@bot.eventasync def on_ready():    print(f'Logged in as {bot.user.name}')@bot.eventasync def on_member_update(before, after):    user1 = discord.utils.get(after.guild.members, name="botid")    user2 = discord.utils.get(after.guild.members, name="myid")    if after.id == user1.id and before.roles != after.roles and user2 in after.roles:        roles_added = [role for role in after.roles if role not in before.roles]        roles_removed = [role for role in before.roles if role not in after.roles]        if roles_added:            await after.remove_roles(*roles_added, reason="Automated action: roles cannot be assigned to user1 by user2")        elif roles_removed:            await after.add_roles(*roles_removed, reason="Automated action: roles cannot be removed from user1 by user2")

A basic role bot that prevents a specific user(me) to set roles to another user(the bot)


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>