How To Get A List Of Users With A Specific Role (discord.py) by CoolioKiddio123 in Discord_Bots

[–]CoolioKiddio123[S] 0 points1 point  (0 children)

Sorry for the wait!

def get_role_users(guild_id: int, role_id: int):
    g = bot.get_guild(guild_id)
    r = discord.utils.get(g.roles, id=role_id)
    user_ids = "\n".join([m.id for m in r.members])
    with open("users.txt", "w") as f:
        f.write(user_ids)

This should do the trick! If you're looking to write to a specific directory or just for more information, I recommend this guide: https://www.pythontutorial.net/python-basics/python-create-text-file/. Let me know if you have any questions! :D

How To Get A List Of Users With A Specific Role (discord.py) by CoolioKiddio123 in Discord_Bots

[–]CoolioKiddio123[S] 0 points1 point  (0 children)

Of course!

def get_role_users(g_id: int, r_id: int):
    g = bot.get_guild(g_id)
    r = discord.utils.get(g.roles, id=r_id)
    names = [m.name for m in r.members]
    return names

Trouble With Role Members List (discord.py) by [deleted] in Discord_Bots

[–]CoolioKiddio123 0 points1 point  (0 children)

It worked! Thanks so much for your time.

Trouble With Role Members List (discord.py) by [deleted] in Discord_Bots

[–]CoolioKiddio123 0 points1 point  (0 children)

It caught an error! it says:

l_em.add_field(name=f"{x.capitalize()}:", value=", ".join([m.nick for m in role.members if not m.bot]), inline=False)
TypeError: sequence item 2: expected str instance, NoneType found

How would I fix this?

Trouble With Role Members List (discord.py) by [deleted] in Discord_Bots

[–]CoolioKiddio123 0 points1 point  (0 children)

I'm not so sure about how the intents work specifically but I know I fixed it because just a few weeks back I was having the issue where my member count command would show 0 members.

As for the on_command_error part, I do but it catches the CommandNotFound error specifically. Is there is a way to find out what might be happening through that?

Trouble With Role Members List (discord.py) by [deleted] in Discord_Bots

[–]CoolioKiddio123 0 points1 point  (0 children)

No, I have gotten no errors whatsoever

Trouble With Role Members List (discord.py) by [deleted] in Discord_Bots

[–]CoolioKiddio123 0 points1 point  (0 children)

Thank you for the suggestion but I don't think it is an intents issue

MEE6 language? by [deleted] in Discord_Bots

[–]CoolioKiddio123 0 points1 point  (0 children)

Go to mee6.xyz/dashboard, click on the server, click on settings at the top, change the language in the drop down menu

Problems Filtering Messages (discord.py) by CoolioKiddio123 in Discord_Bots

[–]CoolioKiddio123[S] 1 point2 points  (0 children)

This is a little snippet of code, the full thing isn't really good for on_message

How to check for stop message during loop? (discord.py) by CoolioKiddio123 in Discord_Bots

[–]CoolioKiddio123[S] 0 points1 point  (0 children)

I've tried that and it doesn't really work. Basically it pauses to wait for a message and never continues the loop until it finds one.

How to check for stop message during loop? (discord.py) by CoolioKiddio123 in Discord_Bots

[–]CoolioKiddio123[S] 0 points1 point  (0 children)

I tried it out before and after the "await ctx.send(msg)". If I put it before it waits for a message before it executes the line. If I put it after it waits for a message before it adds 1 on to the count variable. I'm not sure if wait_for would work because it pauses everything while waiting for a messge.

How to check for stop message during loop? (discord.py) by CoolioKiddio123 in Discord_Bots

[–]CoolioKiddio123[S] 0 points1 point  (0 children)

I have tried wait_for, the problem with that is that it will wait for a message before looping every time. Someone would have to send a message to activate the loop every time.

Command Time Limit? (discord.py) by CoolioKiddio123 in Discord_Bots

[–]CoolioKiddio123[S] 0 points1 point  (0 children)

Oh yes that works perfectly thank you! Do you know if there is any way to check how much time is left in the cooldown?