Example #1
0
        public DiscordMessage SendMessage(string message)
        {
            string url = Endpoints.BaseAPI + Endpoints.Channels + $"/{ID}" + Endpoints.Messages;
            JObject result = JObject.Parse(WebWrapper.Post(url, DiscordClient.token, JsonConvert.SerializeObject(Utils.GenerateMessage(message))));

            DiscordMessage m = new DiscordMessage
            {
                id = result["id"].ToString(),
                attachments = result["attachments"].ToObject<DiscordAttachment[]>(),
                author = this.parent.members.Find(x => x.ID == result["author"]["id"].ToString()),
                channel = this,
                content = result["content"].ToString(),
                RawJson = result,
                timestamp = result["timestamp"].ToObject<DateTime>()
            };
            return m;
        }
        public DiscordMessage SendMessage(string message)
        {
            string url = Endpoints.BaseAPI + Endpoints.Channels + $"/{ID}" + Endpoints.Messages;
            JObject result = JObject.Parse(WebWrapper.Post(url, DiscordClient.token, JsonConvert.SerializeObject(Utils.GenerateMessage(message))));

            if (result["content"].IsNullOrEmpty())
                throw new InvalidOperationException("Request returned a blank message, you may not have permission to send messages yet!");

            DiscordMessage m = new DiscordMessage
            {
                ID = result["id"].ToString(),
                Attachments = result["attachments"].ToObject<DiscordAttachment[]>(),
                Author = this.Parent.GetMemberByKey(result["author"]["id"].ToString()),
                channel = this,
                Content = result["content"].ToString(),
                RawJson = result,
                timestamp = result["timestamp"].ToObject<DateTime>()
            };
            return m;
        }
 private void DeleteMessage(DiscordMessage message)
 {
     string url = Endpoints.BaseAPI + Endpoints.Channels + $"/{ID    }" + Endpoints.Messages + $"/{message.ID}";
     var result = JObject.Parse(WebWrapper.Delete(url, DiscordClient.token));
 }
Example #4
0
 private void DeleteMessage(DiscordMessage message)
 {
     string url    = Endpoints.BaseAPI + Endpoints.Channels + $"/{ID    }" + Endpoints.Messages + $"/{message.id}";
     var    result = JObject.Parse(WebWrapper.Delete(url, DiscordClient.token));
 }