/// <summary> /// Gets a list of messages in this channel. /// <para>Requires <see cref="DiscordPermission.ReadMessages"/>.</para> /// </summary> /// <param name="baseMessageId">The message ID the list will start at (is not included in the final list).</param> /// <param name="limit">Maximum number of messages to be returned.</param> /// <param name="getStrategy">The way messages will be located based on the <paramref name="baseMessageId"/>.</param> /// <exception cref="DiscordHttpApiException"></exception> public Task <IReadOnlyList <DiscordMessage> > GetMessages(Snowflake baseMessageId, int?limit = null, MessageGetStrategy getStrategy = MessageGetStrategy.Before) { return(http.GetChannelMessages(Id, baseMessageId, limit, getStrategy)); }
/// <summary> /// Removes a reaction from this message. /// <para>Requires <see cref="DiscordPermission.ManageMessages"/>.</para> /// </summary> /// <param name="userId">The ID of the user who added the reacted.</param> /// <param name="reactionEmoji"></param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="DiscordHttpApiException"></exception> public Task DeleteUserReaction(Snowflake userId, DiscordReactionEmoji reactionEmoji) { return(http.DeleteUserReaction(ChannelId, Id, userId, reactionEmoji)); }
/// <summary> /// Gets a message in this channel. /// <para>Requires <see cref="DiscordPermission.ReadMessageHistory"/>.</para> /// </summary> /// <exception cref="DiscordHttpApiException"></exception> public Task <DiscordMessage> GetMessage(Snowflake messageId) { return(http.GetChannelMessage(Id, messageId)); }
public DiscordApiData Set(string key, Snowflake snowflake) { throw new NotSupportedException(); }
internal DiscordMessage(DiscordHttpClient http, DiscordApiData data) : base(data) { this.http = http; originalData = data; Content = data.GetString("content"); Timestamp = data.GetDateTime("timestamp").GetValueOrDefault(); EditedTimestamp = data.GetDateTime("edited_timestamp").GetValueOrDefault(); TextToSpeech = data.GetBoolean("tts").GetValueOrDefault(); MentionEveryone = data.GetBoolean("mention_everyone").GetValueOrDefault(); Nonce = data.GetSnowflake("nonce"); IsPinned = data.GetBoolean("pinned").GetValueOrDefault(); ChannelId = data.GetSnowflake("channel_id").GetValueOrDefault(); WebhookId = data.GetSnowflake("webhook_id"); Type = (DiscordMessageType)(data.GetInteger("type") ?? 0); // Get author DiscordApiData authorData = data.Get("author"); if (authorData != null) { Author = new DiscordUser(WebhookId.HasValue, authorData); } // Get mentions IList <DiscordApiData> mentionsArray = data.GetArray("mentions"); if (mentionsArray != null) { DiscordUser[] mentions = new DiscordUser[mentionsArray.Count]; for (int i = 0; i < mentionsArray.Count; i++) { mentions[i] = new DiscordUser(false, mentionsArray[i]); } Mentions = mentions; } // Get mentioned roles IList <DiscordApiData> mentionRolesArray = data.GetArray("mention_roles"); if (mentionRolesArray != null) { Snowflake[] mentionedRoles = new Snowflake[mentionRolesArray.Count]; for (int i = 0; i < mentionRolesArray.Count; i++) { mentionedRoles[i] = mentionRolesArray[i].ToSnowflake().Value; } MentionedRoleIds = mentionedRoles; } // Get attachments IList <DiscordApiData> attachmentsArray = data.GetArray("attachments"); if (attachmentsArray != null) { DiscordAttachment[] attachments = new DiscordAttachment[attachmentsArray.Count]; for (int i = 0; i < attachmentsArray.Count; i++) { attachments[i] = new DiscordAttachment(attachmentsArray[i]); } Attachments = attachments; } // Get embeds IList <DiscordApiData> embedsArray = data.GetArray("embeds"); if (embedsArray != null) { DiscordEmbed[] embeds = new DiscordEmbed[embedsArray.Count]; for (int i = 0; i < embedsArray.Count; i++) { embeds[i] = new DiscordEmbed(embedsArray[i]); } Embeds = embeds; } // Get reactions IList <DiscordApiData> reactionsArray = data.GetArray("reactions"); if (reactionsArray != null) { DiscordReaction[] reactions = new DiscordReaction[reactionsArray.Count]; for (int i = 0; i < reactionsArray.Count; i++) { reactions[i] = new DiscordReaction(reactionsArray[i]); } Reactions = reactions; } }
/// <summary> /// Attaches an integration from the current bot to this guild. /// <para>Requires <see cref="DiscordPermission.ManageGuild"/>.</para> /// </summary> /// <exception cref="DiscordHttpApiException"></exception> public Task CreateIntegration(Snowflake integrationId, string type) { return(http.CreateGuildIntegration(Id, integrationId, type)); }
/// <summary> /// Creates a new value type DiscordApiData object. /// </summary> public DiscordApiData(Snowflake value) { this.value = value.ToString(); // Snowflakes are stored as strings in transit. Type = DiscordApiDataType.Value; }
/// <summary> /// Bans the specified user from this guild. /// <para>Requires <see cref="DiscordPermission.BanMembers"/>.</para> /// </summary> /// <param name="deleteMessageDays">Number of days to delete messages for (0-7) or null to delete none.</param> /// <exception cref="DiscordHttpApiException"></exception> public Task CreateBan(Snowflake userId, int?deleteMessageDays = null) { return(http.CreateGuildBan(Id, userId, deleteMessageDays)); }
/// <summary> /// Unbans the specified user from this guild. /// <para>Requires <see cref="DiscordPermission.BanMembers"/>.</para> /// </summary> /// <exception cref="DiscordHttpApiException"></exception> public Task RemoveBan(Snowflake userId) { return(http.RemoveGuildBan(Id, userId)); }
/// <summary> /// Creates a CDN URL builder for guild splashes. /// </summary> /// <param name="guildId">The ID of the guild.</param> /// <param name="splashHash">The hash of the splash image for the guild.</param> public static DiscordCdnUrl ForGuildSplash(Snowflake guildId, string splashHash) { return(new DiscordCdnUrl(DiscordCdnUrlType.GuildSplash, guildId, splashHash, $"{CdnBaseUrl}/splashes/{guildId}/{splashHash}")); }
/// <summary> /// Gets a member of this guild by their user ID. /// </summary> /// <exception cref="DiscordHttpApiException"></exception> public Task <DiscordGuildMember> GetMember(Snowflake userId) { return(http.GetGuildMember(Id, userId)); }
/// <summary> /// Creates a CDN URL builder for guild icons. /// </summary> /// <param name="guildId">The ID of the guild.</param> /// <param name="iconHash">The icon hash for the guild.</param> public static DiscordCdnUrl ForGuildIcon(Snowflake guildId, string iconHash) { return(new DiscordCdnUrl(DiscordCdnUrlType.GuildIcon, guildId, iconHash, $"{CdnBaseUrl}/icons/{guildId}/{iconHash}")); }
/// <summary> /// Creates a CDN URL builder for custom emojis. /// </summary> /// <param name="emojiId">The ID of the custom emoji.</param> public static DiscordCdnUrl ForCustomEmoji(Snowflake emojiId) { return(new DiscordCdnUrl(DiscordCdnUrlType.CustomEmoji, emojiId, emojiId.ToString(), $"{CdnBaseUrl}/emojis/{emojiId}")); }
/// <summary> /// Creates a CDN URL builder for an application icon. /// </summary> /// <param name="applicationId">The ID of the application.</param> /// <param name="iconHash">The icon hash for the application.</param> public static DiscordCdnUrl ForApplicationIcon(Snowflake applicationId, string iconHash) { return(new DiscordCdnUrl(DiscordCdnUrlType.ApplicationIcon, applicationId, iconHash, $"{CdnBaseUrl}/app-icons/{applicationId}/{iconHash}")); }
/// <summary> /// Creates a CDN URL builder for a user avatar. /// </summary> /// <param name="userId">The ID of the user.</param> /// <param name="avatarHash">The avatar hash for the user.</param> public static DiscordCdnUrl ForUserAvatar(Snowflake userId, string avatarHash) { return(new DiscordCdnUrl(DiscordCdnUrlType.UserAvatar, userId, avatarHash, $"{CdnBaseUrl}/avatars/{userId}/{avatarHash}")); }
internal DiscordIntegration(DiscordHttpClient http, DiscordApiData data, Snowflake guildId) : this(http, data) { GuildId = guildId; }