a year ago
I'm encountering a NameError indicating that guild_id is not defined during the insertion process.
I have the following code for creating the schedules table:
cursor.execute('''
CREATE TABLE IF NOT EXISTS schedules (
guildid BIGINT PRIMARY KEY, channelid BIGINT NOT NULL,
hour INT NOT NULL,
minute INT NOT NULL,
timezone VARCHAR(50) NOT NULL,
frequency ENUM('daily', '2-daily', 'weekly') NOT NULL
)
''')
A
*and this for the callback:(
async def schedule_callback(interaction, frequency, hour, minute, timezone):
await interaction.response.defer()
ctx = [interaction.channel](interaction.channel)
guild_id = [interaction.guild.id](interaction.guild.id)insert
connection = createconnection() cursor = connection.cursor() cursor.execute(''' INSERT INTO schedules (guildid, channelid, hour, minute, timezone, frequency) VALUES (%s, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE guildid = VALUES(guildid), # Adding guildid here
channelid = VALUES(channelid),
hour = VALUES(hour),
minute = VALUES(minute),
timezone = VALUES(timezone),
frequency = VALUES(frequency)
''', (guildid, channelid, hour, minute, timezone, frequency))
connection.commit()
cursor.close()
connection.close()
4 Replies
a year ago
I'm really sorry but we can't provide coding help here
Well I don't believe it's a coding issue seeing it's checked about 20 times.
But thank you.
a year ago
yep this a coding question as it has no relation to railway