#problem with member join event

1 messages · Page 1 of 1 (latest)

toxic abyss
#

code: ```py
@bot.event
async def on_member_join(member):
db = sqlite3.connect("data.db")
cursor = db.cursor()
cursor.execute(f"SELECT channel_id FROM welcomechannel WHERE server_id={member.guild.id}")
result = cursor.fetchone()
id = channel_id = result[0]

channell = bot.get_channel(id)
await channell.send(f"{member} joined!")````
#

no error

sinful beacon
#

Then... What's your problem?

#

I also think that you don't need to open sqlite connection on every event

toxic abyss
#

The message is not sent despite the correct channel id, when I gave wipisan in the console that someone joined also did not unsubscribe

upper lava
#

get_channel can be None

#

Check if get_chabbel is None and if yes, use fetch_channel

toxic abyss
#

ok, but if i given to write something in console on join it alsow not work

upper lava
#

Can you show how you define the bot?

toxic abyss
#

bot = discord.Bot()

upper lava
#

And the intents?

toxic abyss
#

its all

upper lava
#

Did you also add it to the bot?

toxic abyss
#

in dev portal?

#

or what

upper lava
#

At the code

toxic abyss
#

no

#

i added only this

upper lava
#

?tag intents

royal dawnBOT
#

https://docs.pycord.dev/en/master/intents.html
https://discord.com/developers/docs/topics/gateway#gateway-intents

import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

toxic abyss
#

but i would it without prefix

upper lava
#

That is only a intents example

#

You dont add prefix to discord.Bot because its a slash command with it

toxic abyss
#

works

upper lava
#

.close

merry mulchBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @analog viper.

Backup bot: </solved:1109625445990793246> (or .solved) with @merry mulch.

upper lava
#

@toxic abyss Pls close it if you are done

toxic abyss
#

.solved