9
9
9mirrory2021-08-26 13:41:45
Python
9mirrory, 2021-08-26 13:41:45

Gives an error message. How to pass a guild value to create a channel?

async def func():
    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  # для удобства
    guild = Bot.get_guild(id)  # получение названия сервера
    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()

The code throws an error:
Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\79324\Desktop\project\1.py", line 48, in func
    await guild.create_voice_channel("aboba", overwrites=None, category='Classrooms', reason='From command')
  File "C:\Users\79324\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\guild.py", line 987, in create_voice_channel
    data = await self._create_channel(name, overwrites, ChannelType.voice, category, reason=reason, **options)
  File "C:\Users\79324\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\guild.py", line 866, in _create_channel
    parent_id = category.id if category else None
AttributeError: 'str' object has no attribute 'id'

I can't figure out what's wrong

Answer the question

In order to leave comments, you need to log in

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

The category parameter must be an instance of the CategoryChannel class, not a string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question