Discord-Net-Labs/Discord.Net-Labs

Can't create Threads in News (Announcement) channels.

aggiczy opened this issue · 7 comments

Hi there!

I've got this error message when I try to create a thread in a News Channel:

System.NullReferenceException: Object reference not set to an instance of an object.

My method:

(Context.Channel as SocketNewsChannel).CreateThreadAsync("test");

What is the problem in this? Can you fix it please?

Thanks,
Aki26 GamePlay#3982

Is there a stack trace with the exception?

Is there a stack trace with the exception?

Sorry but I don't know exactly what is stack trace. Maybe this?:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Submission#0.<<Initialize>>d__0.MoveNext()

The reason for the excpetion is that Context.Channel is not a SocketNewsChannel, therfor casting it yields null.

But with ITextChannel I get the same error message.

Edit: With ITextChannel I don't get error but it don't create the thread.

So my question: How can I create threads in a News/Announcement channel?

Discord doesn't seem to allow bots to create threads in news
image

Disregard, as pointed out by @NovaFox161 you need to specify ThreadType.NewsThread when creating your thread. An example would be:

var chan = client.GetGuild(guildId).GetTextChannel(newsChannelId);
await chan.CreateThreadAsync("test", ThreadType.NewsThread);