I’m working on a simple Discord Bot with Python. I just want to save guild id on a SQLite folder, I can’t get guild id. I’m new on that database things. Parameters on event doesn’t work like:
JavaScript
x
7
1
@bot.event
2
async def on_guild_join(ctx):
3
dbase = sqlite3.connect('dbase.sqlite')
4
cursor = dbase.cursor()
5
cursor.execute('CREATE TABLE IF NOT EXISTS data(guild_id TEXT)')
6
cursor.execute(f'INSERT INTO data (guild_id) VALUES ({ctx.guild.id})')
7
Advertisement
Answer
on_guild_join only has the parameter of Guild and not Context.
JavaScript
1
7
1
@bot.event
2
async def on_guild_join(guild):
3
dbase = sqlite3.connect('dbase.sqlite')
4
cursor = dbase.cursor()
5
cursor.execute('CREATE TABLE IF NOT EXISTS data(guild_id TEXT)')
6
cursor.execute(f'INSERT INTO data (guild_id) VALUES ({guild.id})')
7