/// <summary> /// Gets messages in a channel. /// </summary> /// <param name="channelId">The channel's id.</param> /// <param name="guildId">The id of the guild the channel belongs to.</param> /// <param name="beforeId">The message to get the messages from before.</param> public async Task <Message[]> GetMessagesAsync(ulong channelId, ulong?guildId = null, ulong?beforeId = null) { Guard.IsNotNull(_client.ChannelService, nameof(_client.ChannelService)); Func <Task <JsonMessage[]> > request = () => _client.ChannelService.GetChannelMessages(channelId); if (beforeId.HasValue) { request = () => _client.ChannelService.GetChannelMessagesBefore(channelId, beforeId.Value); } JsonMessage[] jsonMessages = await _client.MakeRefitRequest(request) ?? Array.Empty <JsonMessage>(); Message[] messages = new Message[jsonMessages.Length]; for (int i = 0; i < messages.Length; i++) { jsonMessages[i].GuildId ??= guildId; messages[i] = new Message(jsonMessages[i], _client); } return(messages); }
/// <summary> /// Modifies the current user. /// </summary> /// <param name="modifyUser">The self user modifications.</param> public async Task ModifyMe(ModifySelfUser modifyUser) { Guard.IsNotNull(_client.UserService, nameof(UserService)); await _client.MakeRefitRequest(() => _client.UserService.ModifyMe(modifyUser.ToJsonModel())); }