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

Discord.js Bot Welcomes Member, Assign a Role and send them a DM

Your code looks fine, the problem is that the event isn’t triggered. Thats because discord turned off “privileged intents” by default. Some intents are defined as “Privileged” due to the sensitive nature of the data. Those intents are: GUILD_PRESENCES GUILD_MEMBERS One effect of that is what you are experiencing, the not working guildMemberAdd event. The … Read more

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

Discord.py on_member_join not working, no error message

With version >1.5.0 you can do something like this: import discord intents = discord.Intents.default() intents.members = True client = discord.Client(intents=intents) @client.event async def on_member_join(member): await member.send(“Welcome!”) You also need to enable intents in the developer portal in https://discord.com/developers/applications. Bot > Bot > Presence & Server Members Intents > Toggle On