Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Fails to Create Forum Channel #74

Open
malikmajai opened this issue Feb 10, 2024 · 9 comments
Open

[Bug]: Fails to Create Forum Channel #74

malikmajai opened this issue Feb 10, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@malikmajai
Copy link

Description

I am not able to create a forum channel. Here is my code:

GUILD_ID = 0
CATEGORY_ID = 0
guild: discord.Guild = bot.get_guild(GUILD_ID)
category: discord.CategoryChannel = bot.get_channel(CATEGORY_ID)
await guild.create_forum_channel(name='Test', category=category)
    ```
 

### Branch used

developer

### The Python version you are using.

Python 3.10

### What version (and release) of the library are you using

2.0a643+g33f5246

### System info

Windows 11

### Full Traceback (Error)

```shell
Traceback (most recent call last):
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 454, in _run_event
    await coro(*args, **kwargs)
  File "d:\Bots\illegalshirts\main.py", line 27, in on_ready
    await guild.create_forum_channel(name='Test', category=category)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\guild.py", line 1632, in create_forum_channel
    data = await self._create_channel(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\guild.py", line 1359, in _create_channel 
    raise InvalidArgument(
discord.errors.InvalidArgument: None is not a valid default_auto_archive_duration

Contact info

No response

@malikmajai malikmajai added the bug Something isn't working label Feb 10, 2024
@mccoderpy
Copy link
Owner

mccoderpy commented Feb 10, 2024

Just to ask, why are you using bot.get_channel if you got the guild? Just use guild.get_channel (it's much faster)🙈

@malikmajai
Copy link
Author

malikmajai commented Feb 10, 2024

Oh

@malikmajai
Copy link
Author

Didn't knew guild.get_channel is faster than bot.get_channel

@mccoderpy
Copy link
Owner

Didn't knew guild.get_channel is faster than bot.get_channel

Of course it is
bot.get_channel ->

def get_channel(self, id):
if id is None:
return None
pm = self._get_private_channel(id)
if pm is not None:
return pm
for guild in self.guilds:
channel = guild.get_channel(id)
if channel is not None:
return channel
# We assume it is an uncached privat channel here, this may be false

@The-LukeZ
Copy link

Btw. you just need to provide an default_auto_archive_duration (which should be 7 or 3 days). Then it works.

@malikmajai
Copy link
Author

guild: discord.Guild = bot.get_guild(GUILD_ID)
category: discord.CategoryChannel = bot.get_channel(CATEGORY_ID)
await guild.create_forum_channel(name='Test', category=category)

By default it is None, it should work with default value also
image

@mccoderpy
Copy link
Owner

guild: discord.Guild = bot.get_guild(GUILD_ID)
category: discord.CategoryChannel = bot.get_channel(CATEGORY_ID)
await guild.create_forum_channel(name='Test', category=category)

By default it is None, it should work with default value also
image

Yea the check is wrong. It should just drop the field if it is None, as every field except name is nullable for the guild channel endpoint.

@malikmajai
Copy link
Author

Hi bro, do we have a new server for this library?

@mccoderpy
Copy link
Owner

Hi bro, do we have a new server for this library?

In theory yes...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants