Discord Bot can only see itself and no other users in guild

Enable the server members intent near the bottom of the Bot tab of your Discord Developer Portal: Change the line client = discord.Client() to this: intents = discord.Intents.default() intents.members = True client = discord.Client(intents=intents) This makes your bot request the “members” gateway intent. What are gateway intents? Intents allow you to subscribe to certain events. … Read more

Python – DM a User Discord Bot

The easiest way to do this is with the discord.ext.commands extension. Here we use a converter to get the target user, and a keyword-only argument as an optional message to send them: from discord.ext import commands import discord bot = commands.Bot(command_prefix=’!’) @bot.command(pass_context=True) async def DM(ctx, user: discord.User, *, message=None): message = message or “This Message … Read more

How do I use cogs with discord.py?

Note: The below was written for the older 0.16 version, which did not have good documentation of cogs. The new 1.0 version has good documentation, and has completely changed the structure of cogs. If you’re using a modern version of discord.py, you should consult the official documentation. Introduction Every cog has two parts: a class … Read more

How do I mention a user in discord.py?

So I finally figured out how to do this after few days of trial and error hoping others would benefit from this and have less pain than I actually had.. The solution was ultimately easy.. if message.content.startswith(‘!best’): myid = ‘<@201909896357216256>’ await client.send_message(message.channel, ‘ : %s is the best ‘ % myid)

Why doesn’t multiple on_message events work?

It’s not possible with the native Client You can only have one on_message, if you have multiple, only the last one will be called for the on_message event. You’ll just need to combine your three on_message. import discord client = discord.Client() @client.event async def on_message(message): print(“in on_message #1”) print(“in on_message #2”) print(“in on_message #3”) client.run(“TOKEN”) … Read more

Commands don’t run in discord.py 2.0 – no errors, but run in discord.py 1.7.3

Use Intents with discord.py 2.0 Enable Intents On Discord Developer Portal Select your application Click on the Bot section And check MESSAGE CONTENT INTENT Add your intents to the bot Let’s add the message_content Intent now. import discord from discord.ext import commands intents = discord.Intents.default() intents.message_content = True bot = commands.Bot(command_prefix=’$’, intents=intents, help_command=None) Put it … Read more