diff --git a/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannel.cs b/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannel.cs
index 0f4c9b060..69aeba514 100644
--- a/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannel.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/WelcomeScreenChannel.cs
@@ -40,4 +40,17 @@ public class WelcomeScreenChannel : ISnowflakeEntity
Emoji = null;
}
+
+ ///
+ /// Initializes a new instance of to be used to modify one.
+ ///
+ ///
+ ///
+ ///
+ public WelcomeScreenChannel(ulong id, string description, IEmote emoji)
+ {
+ Id = id;
+ Description = description;
+ Emoji = emoji;
+ }
}
diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildWelcomeScreenParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildWelcomeScreenParams.cs
new file mode 100644
index 000000000..7deb7209e
--- /dev/null
+++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildWelcomeScreenParams.cs
@@ -0,0 +1,17 @@
+using Newtonsoft.Json;
+
+namespace Discord.API.Rest;
+
+
+[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
+internal class ModifyGuildWelcomeScreenParams
+{
+ [JsonProperty("enabled")]
+ public Optional Enabled { get; set; }
+
+ [JsonProperty("welcome_channels")]
+ public Optional Channels { get; set; }
+
+ [JsonProperty("description")]
+ public Optional Description { get; set; }
+}
diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs
index dd57dba51..cefffadd4 100644
--- a/src/Discord.Net.Rest/DiscordRestApiClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs
@@ -1589,18 +1589,6 @@ namespace Discord.API
var ids = new BucketIds(guildId: guildId);
return await SendAsync("GET", () => $"guilds/{guildId}/prune?days={args.Days}{endpointRoleIds}", ids, options: options).ConfigureAwait(false);
}
- public async Task GetGuildWelcomeScreenAsync(ulong guildId, RequestOptions options = null)
- {
- Preconditions.NotEqual(guildId, 0, nameof(guildId));
- options = RequestOptions.CreateOrClone(options);
-
- try
- {
- var ids = new BucketIds(guildId: guildId);
- return await SendAsync("GET", () => $"guilds/{guildId}/welcome-screen", ids, options: options).ConfigureAwait(false);
- }
- catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; }
- }
#endregion
#region Guild Bans
@@ -2109,6 +2097,35 @@ namespace Discord.API
#endregion
+ #region Guild Welcome Screen
+
+ public async Task GetGuildWelcomeScreenAsync(ulong guildId, RequestOptions options = null)
+ {
+ Preconditions.NotEqual(guildId, 0, nameof(guildId));
+ options = RequestOptions.CreateOrClone(options);
+
+ try
+ {
+ var ids = new BucketIds(guildId: guildId);
+ return await SendAsync("GET", () => $"guilds/{guildId}/welcome-screen", ids, options: options).ConfigureAwait(false);
+ }
+ catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; }
+ }
+
+ public async Task ModifyGuildWelcomeScreenAsync(ModifyGuildWelcomeScreenParams args, ulong guildId, RequestOptions options = null)
+ {
+ Preconditions.NotEqual(guildId, 0, nameof(guildId));
+ Preconditions.NotNull(args, nameof(args));
+
+ options = RequestOptions.CreateOrClone(options);
+
+ var ids = new BucketIds(guildId: guildId);
+
+ return await SendJsonAsync("PATCH", () => $"guilds/{guildId}/welcome-screen", args, ids, options: options).ConfigureAwait(false);
+ }
+
+ #endregion
+
#region Users
public async Task GetUserAsync(ulong userId, RequestOptions options = null)
{
diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
index a4d0de0ee..18b82344f 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
@@ -393,16 +393,6 @@ namespace Discord.Rest
return RestInviteMetadata.Create(client, guild, null, inviteModel);
}
- public static async Task GetWelcomeScreenAsync(IGuild guild, BaseDiscordClient client, RequestOptions options)
- {
- var model = await client.ApiClient.GetGuildWelcomeScreenAsync(guild.Id, options);
-
- return new WelcomeScreen(model.Description.GetValueOrDefault(null), model.WelcomeChannels.Select(
- x => new WelcomeScreenChannel(
- x.ChannelId, x.Description,
- x.EmojiName.GetValueOrDefault(null),
- x.EmojiId.GetValueOrDefault(0))).ToList());
- }
#endregion
#region Roles
@@ -954,5 +944,31 @@ namespace Discord.Rest
}
#endregion
+
+ #region Welcome Screen
+
+ public static async Task GetWelcomeScreenAsync(IGuild guild, BaseDiscordClient client, RequestOptions options)
+ {
+ var model = await client.ApiClient.GetGuildWelcomeScreenAsync(guild.Id, options);
+
+ return new WelcomeScreen(model.Description.GetValueOrDefault(null), model.WelcomeChannels.Select(
+ x => new WelcomeScreenChannel(
+ x.ChannelId, x.Description,
+ x.EmojiName.GetValueOrDefault(null),
+ x.EmojiId.GetValueOrDefault(0))).ToList());
+ }
+
+ public static async Task ModifyWelcomeScreenAsync(IGuild guild, BaseDiscordClient client, RequestOptions options)
+ {
+ var model = await client.ApiClient.ModifyGuildWelcomeScreenAsync(null, guild.Id, options);
+
+ return new WelcomeScreen(model.Description.GetValueOrDefault(null), model.WelcomeChannels.Select(
+ x => new WelcomeScreenChannel(
+ x.ChannelId, x.Description,
+ x.EmojiName.GetValueOrDefault(null),
+ x.EmojiId.GetValueOrDefault(0))).ToList());
+ }
+
+ #endregion
}
}