Пример #1
0
        public async Task <ActionResult> Command_DeleteMessageAsync(
            [Name("Message")][Description("The ID of the message to delete.")]
            ulong messageId,
            [Name("Silence")][Description("Whether to respond with confirmation of the deletion.")]
            bool silent = false)
        {
            var message = await Context.Channel.GetMessageAsync(messageId).ConfigureAwait(false);

            if (message == null)
            {
                return(BadRequest("Couldn't find the message."));
            }
            var success = await message.TryDeleteAsync(RequestOptionsHelper.AuditLog($"Requested by {Context.Invoker} at {DateTime.UtcNow.ToUniversalTime():F}"));

            if (success && !silent)
            {
                return(Ok());
            }
            else if (success)
            {
                return(Empty());
            }
            else
            {
                return(BadRequest("Failed to delete message."));
            }
        }
Пример #2
0
        public async Task <ActionResult> LeaveGuild([FromRoute] string id)
        {
            var u     = ulong.Parse(id);
            var guild = _client.GetGuild(u);

            if (guild == null)
            {
                return(BadRequest(new { message = "Invalid ID." }));
            }
            await guild.LeaveAsync(RequestOptionsHelper.AuditLog("Web UI"));

            return(Ok());
        }