This seems like a popular error, but I can't for the life of me find a fix that'll work for me. I'm trying to give a member a role whenever they join my server but every time it reaches await member.add_roles(member, role)
it sends off the error in the title. I've tried testing in the on_message
function with the exact same results.
import os
import discord
from discord.ext import commands
from replit import db
client = discord.Client()
intents = discord.Intents.all()
client = commands.Bot('PREFIX',intents=intents)
@client.event
async def on_ready():
print("I'm in")
print(client.user)
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == "ping":
await message.channel.send("pong")
@client.event
async def on_member_join(member):
print(f"{member} has joined")
role = discord.utils.get(member.guild.roles, name="Member")
await member.add_roles(member, role)
client.run(token)
CodePudding user response:
print(f"{member} has joined")
role = discord.utils.get(member.guild.roles, name="Member")
await member.add_roles(member, role) # member argument is causing issue, remove that
member is discord.Member
object, if you put that in add_roles, it will error out and throw discord.NotFound 404
print(f"{member} has joined")
role = discord.utils.get(member.guild.roles, name="Member")
await member.add_roles(role)
also consider getting rid of that client = discord.Client()
line, it's quite useless