9
9
9mirrory2021-08-26 12:28:53
Python
9mirrory, 2021-08-26 12:28:53

How to create voice channel by passing server value from database without ctx?

I need to create a voice channel, having a pre-passed server id value. But when I want to get the server name via guild = Bot.get_guild(id) the guild variable is set to None. Is it even possible to create a channel without ctx? Or should I record the name of the server in the database?

async def func():
    print('addin...') #индикатор
    conn = sqlite3.connect("timings.db")
    c = conn.cursor()
    s = c.execute("""SELECT sid FROM requests ORDER BY month,day,hour,minute""") #сортировка по дате и времени для нахождения в базе данных самых ранних дат
    sid = s.fetchone() #вывод id сервера
    sid = sid[0] #вывод значения из кортежа
    id = sid #для удобства
    print(id) #индикатор
    guild = Bot.get_guild(id) #получение названия сервера
    print(guild) #индикатор
    await guild.create_voice_channel("aboba", overwrites=None, category='Classrooms', reason='From command')
    c.execute("""DELETE month, day, hour, minute, sid, cid FROM requests ORDER BY month,day,hour,minute""")
    conn.commit()
    conn.close()


Here is the error:
await guild.create_voice_channel("aboba", overwrites=None, category='Classrooms', reason='From command')
AttributeError: 'NoneType' object has no attribute 'create_voice_channel'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-08-26
@9mirrory

So there is no server with that ID.
Also ID must be a number

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question