I would like to have a command to get a list of ALL users with a special role. But this doesn't really work.
Everything is output, but not the members. Does anyone here have an idea what this is about? Or even a better alternative?
Many thanks in advance
import discord
import asyncio
from discord import message
from discord.ext import commands
intents = discord.Intents.all()
client = discord.Client(intents=intents)
class ClansCog(commands.Cog, name='Clans'):
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
async def deutsch(self, ctx, *args):
if ctx.channel.type is not discord.ChannelType.private:
await ctx.message.delete()
roll_id = 733988944--------
guild_id = 71911198261------
guild = self.bot.get_guild(guild_id)
partner_role = guild.get_role(roll_id)
print(partner_role.members)
print(partner_role.id)
print(client.guilds)
def setup(bot):
bot.add_cog(ClansCog(bot))
print('Clans loaded!')
From Terminal
[]
733988944533-------
[]
A friend and I found the problem. It was an intents problem (thanks Shnap :) )
bot = commands.Bot(command_prefix='d!'.lower(), case_insensitive=True, intents=intents)
intents=intents was missing, after that no more problem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.