#entire bot doesnt work help

1 messages · Page 1 of 1 (latest)

inner geyser
vocal iron
#

I'm sorry but you have to give us something to work with. I at least am not interested looking over the code trying to guess what's failing.
Please provide as much information as possible when asking for help.
Please help it don't work is not good enough

inner geyser
#

it says an index error on the listener

#

i think its because it doesn't register some data but i cant figure out how to fix

vocal iron
#
    await cursor.execute("SELECT staff_role_id, ticket_msg FROM ticket_db WHERE server_id=?", (inter.guild.id,))
    result = await cursor.fetchall()
    print(result)
    if result:
        staff_role = result[0]
        ticket_msg = result[1]
        staff_role = inter.guild.get_role(staff_role)

are you expecting one result here ?

#

show me what the print(result) shows and ill explain why its failing catsip

inner geyser
#

[(1060941867505684510, 'ss')]

vocal iron
#

Yupp!

inner geyser
#

shows only this

vocal iron
#

Ok,
when you use SELECT, the result will always be returned as a tuple, and you always get a list
so as you see from the print out you have a list []
with a single tuple () inside it
both are sequences. so what you really need to do is
result[0][0]
go into the first element in the list, and then the first element of the tuple

#

fetchone() might give a tuple without the list, but you always get tuples

#

Makes sense?

inner geyser
#

maybe

#

so how can i fix it

vocal iron
#

thats a no then. ok

    await cursor.execute("SELECT staff_role_id, ticket_msg FROM ticket_db WHERE server_id=?", (inter.guild.id,))
    result = await cursor.fetchall()
    print(result)
    #[ (1060941867505684510, 'ss') ] List with 1 element
    if result:
        staff_role = result[0] #< Get me first element in list. => (1060941867505684510, 'ss')
        ticket_msg = result[1] #< Get me second element in the list? There only exists one element => ERROR
        correct = result[0][0] #< Get me the first element in the first element of the list. => 1060941867505684510
        correct2 = result[0][1] #< Second element of the first element in the list. => 'ss'
        staff_role = inter.guild.get_role(staff_role)
inner geyser
#

thanks

#

i will try

vocal iron
#

did you understand it now?

inner geyser
#

yes thanks