#I need help with my discord bot, I can't get the it to welcome a new member even though code is good

7 messages · Page 1 of 1 (latest)

prime vapor
#

The code is,

import discord
import responses
from discord.utils import get

async def send_message(message, user_message, is_private):
    try:
        response = responses.get_response(user_message)
        await message.author.send(response) if is_private else await message.channel.send(response)

    except Exception as e:
        print(e)


    
def run_discord_bot():
    TOKEN = 'myactualtokengoeshereiknow'
    intents = discord.Intents.default()
    intents.message_content = True
    client = discord.Client(intents=intents)    
    @client.event
    async def on_ready():
        print(f'{client.user} is now running!')

    @client.event
    async def on_message(message):
        if message.author == client.user:
            return

        username = str(message.author)
        user_message = str(message.content)
        channel = str(message.channel)
        print(channel)

        print(f'{username} said: "{user_message}" ({channel})')

        if user_message[0] == '?':
            user_message = user_message[1:]
            await send_message(message, user_message, is_private=True)
        else:
            await send_message(message, user_message, is_private=False)
    
        @client.event
        async def on_member_join(member):
            channel = client.get_channel(id=1092908820239482960)
            await channel.send(f"{member.mention} has just joined the server!")

                
    client.run(TOKEN)

Please help me get it running

#

I think the issue is with the intents if anyone can guide me

prime vapor
#

Made some progress

#

module 'discord' has no attribute 'get_utils'

#

I get this now

#
import discord
from discord.ext import commands
import datetime

welcome_channel= 1092908820239482960

bot=commands.Bot(command_prefix=".",intents=discord.Intents.all())
@bot.event
async def on_ready():
    print ("The bot is ready")
@bot.event
async def on_member_join(member):
    try:
        channel = bot.get_channel(welcome_channel)
        embed= discord.Embed(
            description=f"Welcome To The Crew, {member.mention}",
            color=0xff55ff,
            timestamp=datetime.datetime.now()
            )
        role = discord.get_utils.get(member.guild.roles, name="Member")
        await member.add_role(role)
        await channel.send(embed=embed)
    except Exception as e:
        print(e)
bot.run("myactualtokesishere")
heady kayak
#

It's just utils not get_utils