示例#1
0
        protected override async Task _Invoke(MessageContext context)
        {
            DiscordMessage checkingMessage = await context.Reply("Checking reddit API connection status...").ConfigureAwait(false);

            bool apiIsEstablished = Reddit.ApiIsEstablished();

            if (apiIsEstablished)
            {
                await context.Reply(":white_check_mark: The connection to the Reddit API appears to be working").ConfigureAwait(false);
            }
            else
            {
                await context.Reply(":x: Error: It appears the connection to the Reddit API is not working").ConfigureAwait(false);
            }

            await checkingMessage.DeleteAsync().ConfigureAwait(false);
        }
示例#2
0
        protected override async Task _Invoke(MessageContext context)
        {
            var initialMessage = "Attempting to establish Reddit API, ";

            string[] splitMessage = Regex.Split(context.MessageString, @"[\s+]");
            if (!(splitMessage.Length > 2 && int.TryParse(splitMessage[2], out var timeout)))
            {
                timeout = Reddit.DefaultTimeout;
            }

            initialMessage += $"timeout={timeout}ms...";
            await context.Reply(initialMessage).ConfigureAwait(false);

            await context.Reply(await Reddit.EstablishApi(timeout).ConfigureAwait(false)
                                ? "Reddit API successfully established!"
                                : "Error: could not establish Reddit API.").ConfigureAwait(false);
        }