@@ -8,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks;
using WidgetModel = Discord.API.GuildWidget;
using Model = Discord.API.Guild;
using System.IO;
namespace Discord.Rest
{
@@ -946,6 +947,42 @@ namespace Discord.Rest
return CustomSticker.Create(Discord, model, this, model.User.IsSpecified ? model.User.Value.Id : null);
}
/// <summary>
/// Creates a new sticker in this guild
/// </summary>
/// <param name="name">The name of the sticker.</param>
/// <param name="description">The description of the sticker.</param>
/// <param name="tags">The tags of the sticker.</param>
/// <param name="path">The path of the file to upload.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the created sticker.
/// </returns>
public Task<CustomSticker> CreateStickerAsync(string name, string description, IEnumerable<string> tags, string path,
RequestOptions options = null)
{
var fs = File.OpenRead(path);
return CreateStickerAsync(name, description, tags, fs, Path.GetFileName(fs.Name), options);
}
/// <summary>
/// Creates a new sticker in this guild
/// </summary>
/// <param name="name">The name of the sticker.</param>
/// <param name="description">The description of the sticker.</param>
/// <param name="tags">The tags of the sticker.</param>
/// <param name="stream">The stream containing the file data.</param>
/// <param name="filename">The name of the file <b>with</b> the extension, ex: image.png</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the created sticker.
/// </returns>
public async Task<CustomSticker> CreateStickerAsync(string name, string description, IEnumerable<string> tags, Stream stream,
string filename, RequestOptions options = null)
{
var model = await GuildHelper.CreateStickerAsync(Discord, this, name, description, tags, stream, filename, options).ConfigureAwait(false);
return CustomSticker.Create(Discord, model, this, model.User.IsSpecified ? model.User.Value.Id : null);
}
/// <summary>
/// Gets a specific sticker within this guild.
/// </summary>
/// <param name="id">The id of the sticker to get.</param>
@@ -1262,8 +1299,16 @@ namespace Discord.Rest
/// <inheritdoc />
async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (RequestOptions options)
=> await GetApplicationCommandsAsync(options).ConfigureAwait(false);
/// <inheritdoc />
async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Image image, RequestOptions options)
=> await CreateStickerAsync(name, description, tags, image, options);
/// <inheritdoc />
async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Stream stream, string filename, RequestOptions options)
=> await CreateStickerAsync(name, description, tags, stream, filename, options);
/// <inheritdoc />
async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, string path, RequestOptions options)
=> await CreateStickerAsync(name, description, tags, path, options);
/// <inheritdoc />
async Task<ICustomSticker> IGuild.GetStickerAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode != CacheMode.AllowDownload)
@@ -1271,6 +1316,7 @@ namespace Discord.Rest
return await GetStickerAsync(id, options);
}
/// <inheritdoc />
async Task<IReadOnlyCollection<ICustomSticker>> IGuild.GetStickersAsync(CacheMode mode, RequestOptions options)
{
if (mode != CacheMode.AllowDownload)
@@ -1278,6 +1324,7 @@ namespace Discord.Rest
return await GetStickersAsync(options);
}
/// <inheritdoc />
Task IGuild.DeleteStickerAsync(ICustomSticker sticker, RequestOptions options)
=> sticker.DeleteAsync();
}