/// <summary> /// Creates a thread within this <see cref="ITextChannel"/>. /// </summary> /// <remarks> /// When <paramref name="message"/> is <see langword="null"/> the thread type will be based off of the /// channel its created in. When called on a <see cref="ITextChannel"/>, it creates a <see cref="ThreadType.PublicThread"/>. /// When called on a <see cref="INewsChannel"/>, it creates a <see cref="ThreadType.NewsThread"/>. The id of the created /// thread will be the same as the id of the message, and as such a message can only have a /// single thread created from it. /// </remarks> /// <param name="name">The name of the thread.</param> /// <param name="type"> /// The type of the thread. /// <para> /// <b>Note: </b>This parameter is not used if the <paramref name="message"/> parameter is not specified. /// </para> /// </param> /// <param name="autoArchiveDuration"> /// The duration on which this thread archives after. /// <para> /// <b>Note: </b> Options <see cref="ThreadArchiveDuration.OneWeek"/> and <see cref="ThreadArchiveDuration.ThreeDays"/> /// are only available for guilds that are boosted. You can check in the <see cref="IGuild.Features"/> to see if the /// guild has the <b>THREE_DAY_THREAD_ARCHIVE</b> and <b>SEVEN_DAY_THREAD_ARCHIVE</b>. /// </para> /// </param> /// <param name="message">The message which to start the thread from.</param> /// <param name="options">The options to be used when sending the request.</param> /// <returns> /// A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/> /// </returns> public virtual async Task <RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool?invitable = null, int?slowmode = null, RequestOptions options = null) { var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options); return(RestThreadChannel.Create(Discord, Guild, model)); }
internal ThreadInfo(string name, bool archived, ThreadArchiveDuration autoArchiveDuration, bool locked, int?rateLimit) { Name = name; IsArchived = archived; AutoArchiveDuration = autoArchiveDuration; IsLocked = locked; SlowModeInterval = rateLimit; }
/// <summary> /// Creates a thread within this <see cref="ITextChannel"/>. /// </summary> /// <remarks> /// When <paramref name="message"/> is <see langword="null"/> the thread type will be based off of the /// channel its created in. When called on a <see cref="ITextChannel"/>, it creates a <see cref="ThreadType.PublicThread"/>. /// When called on a <see cref="INewsChannel"/>, it creates a <see cref="ThreadType.NewsThread"/>. The id of the created /// thread will be the same as the id of the message, and as such a message can only have a /// single thread created from it. /// </remarks> /// <param name="name">The name of the thread.</param> /// <param name="type"> /// The type of the thread. /// <para> /// <b>Note: </b>This parameter is not used if the <paramref name="message"/> parameter is not specified. /// </para> /// </param> /// <param name="autoArchiveDuration"> /// The duration on which this thread archives after. /// <para> /// <b>Note: </b> Options <see cref="ThreadArchiveDuration.OneWeek"/> and <see cref="ThreadArchiveDuration.ThreeDays"/> /// are only available for guilds that are boosted. You can check in the <see cref="IGuild.Features"/> to see if the /// guild has the <b>THREE_DAY_THREAD_ARCHIVE</b> and <b>SEVEN_DAY_THREAD_ARCHIVE</b>. /// </para> /// </param> /// <param name="message">The message which to start the thread from.</param> /// <param name="options">The options to be used when sending the request.</param> /// <returns> /// A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/> /// </returns> public virtual async Task <SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool?invitable = null, int?slowmode = null, RequestOptions options = null) { var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options); var thread = (SocketThreadChannel)Guild.AddOrUpdateChannel(Discord.State, model); await thread.DownloadUsersAsync(); return(thread); }
private ThreadDeleteAuditLogData(ulong id, string name, ThreadType type, bool archived, ThreadArchiveDuration autoArchiveDuration, bool locked, int?rateLimit) { ThreadId = id; ThreadName = name; ThreadType = type; IsArchived = archived; AutoArchiveDuration = autoArchiveDuration; IsLocked = locked; SlowModeInterval = rateLimit; }
public static async Task <Model> CreateThreadAsync(BaseDiscordClient client, ITextChannel channel, string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool?invitable = null, int?slowmode = null, RequestOptions options = null) { var features = channel.Guild.Features; if (autoArchiveDuration == ThreadArchiveDuration.OneWeek && !features.HasFeature(GuildFeature.SevenDayThreadArchive)) { throw new ArgumentException($"The guild {channel.Guild.Name} does not have the SEVEN_DAY_THREAD_ARCHIVE feature!", nameof(autoArchiveDuration)); } if (autoArchiveDuration == ThreadArchiveDuration.ThreeDays && !features.HasFeature(GuildFeature.ThreeDayThreadArchive)) { throw new ArgumentException($"The guild {channel.Guild.Name} does not have the THREE_DAY_THREAD_ARCHIVE feature!", nameof(autoArchiveDuration)); } if (type == ThreadType.PrivateThread && !features.HasFeature(GuildFeature.PrivateThreads)) { throw new ArgumentException($"The guild {channel.Guild.Name} does not have the PRIVATE_THREADS feature!", nameof(type)); } if (channel is INewsChannel && type != ThreadType.NewsThread) { throw new ArgumentException($"{nameof(type)} must be a {ThreadType.NewsThread} in News channels"); } var args = new StartThreadParams { Name = name, Duration = autoArchiveDuration, Type = type, Invitable = invitable.HasValue ? invitable.Value : Optional <bool> .Unspecified, Ratelimit = slowmode.HasValue ? slowmode.Value : Optional <int?> .Unspecified, }; Model model; if (message != null) { model = await client.ApiClient.StartThreadAsync(channel.Id, message.Id, args, options).ConfigureAwait(false); } else { model = await client.ApiClient.StartThreadAsync(channel.Id, args, options).ConfigureAwait(false); } return(model); }
/// <inheritdoc /> internal override void Update(Model model) { base.Update(model); CategoryId = model.CategoryId; Topic = model.Topic.GetValueOrDefault(); if (model.SlowMode.IsSpecified) { SlowModeInterval = model.SlowMode.Value; } IsNsfw = model.Nsfw.GetValueOrDefault(); if (model.AutoArchiveDuration.IsSpecified) { DefaultArchiveDuration = model.AutoArchiveDuration.Value; } else { DefaultArchiveDuration = ThreadArchiveDuration.OneDay; } // basic value at channel creation. Shouldn't be called since guild text channels always have this property }
/// <inheritdoc /> async Task <IThreadChannel> ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, bool?invitable, int?slowmode, RequestOptions options) => await CreateThreadAsync(name, type, autoArchiveDuration, message, invitable, slowmode, options);
public Task <IThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool?invitable = null, int?slowmode = null, RequestOptions options = null) => throw new NotImplementedException();
/// <inheritdoc cref="IForumChannel.CreatePostWithFilesAsync(string, IEnumerable{FileAttachment}, ThreadArchiveDuration, int?, string, Embed, RequestOptions, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags)"/> public Task <RestThreadChannel> CreatePostWithFilesAsync(string title, IEnumerable <FileAttachment> attachments, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int?slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) => ThreadHelper.CreatePostAsync(this, Discord, title, attachments, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags);
/// <inheritdoc cref="IForumChannel.CreatePostWithFileAsync(string, Stream, string, ThreadArchiveDuration, int?, string, Embed, RequestOptions, bool, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags)"/> public async Task <RestThreadChannel> CreatePostWithFileAsync(string title, Stream stream, string filename, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int?slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) { using var file = new FileAttachment(stream, filename, isSpoiler: isSpoiler); return(await ThreadHelper.CreatePostAsync(this, Discord, title, new FileAttachment[] { file }, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags).ConfigureAwait(false)); }
async Task <IThreadChannel> IForumChannel.CreatePostWithFilesAsync(string title, IEnumerable <FileAttachment> attachments, ThreadArchiveDuration archiveDuration, int?slowmode, string text, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await CreatePostWithFilesAsync(title, attachments, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags);
async Task <IThreadChannel> IForumChannel.CreatePostWithFileAsync(string title, Stream stream, string filename, ThreadArchiveDuration archiveDuration, int?slowmode, string text, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags) => await CreatePostWithFileAsync(title, stream, filename, archiveDuration, slowmode, text, embed, options, isSpoiler, allowedMentions, components, stickers, embeds, flags).ConfigureAwait(false);
/// <inheritdoc/> /// <exception cref="InvalidOperationException">Cannot create a thread within a voice channel.</exception> public override Task <RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool?invitable = null, int?slowmode = null, RequestOptions options = null) => throw new InvalidOperationException("Cannot create a thread within a voice channel");
public static async Task <RestThreadChannel> CreatePostAsync(IForumChannel channel, BaseDiscordClient client, string title, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int?slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None) { embeds ??= Array.Empty <Embed>(); if (embed != null) { embeds = new[] { embed } }