Пример #1
0
        public async Task FetchAllarJoke(CommandContext Context)
        {
            await LogHandlerService.LogUserActionAsync(Context, "Invoked Allar Joke");

            if (!await DiscordHelpers.AttemptChargeDallarForCommand(Context, 1))
            {
                await LogHandlerService.LogUserActionAsync(Context, "Failed charged for Allar Joke");

                return;
            }

            await LogHandlerService.LogUserActionAsync(Context, "Successfully charged for Allar Joke");

            await Context.TriggerTypingAsync();

            var httpClient = new HttpClient();
            var content    = await httpClient.GetStringAsync("http://api.icndb.com/jokes/random?firstName=Michael&lastName=Allar");

            try
            {
                dynamic jokeResult = JsonConvert.DeserializeObject(content);
                string  joke       = jokeResult.value.joke;
                joke = System.Net.WebUtility.HtmlDecode(joke);
                await Context.RespondAsync($"{Context.User.Mention} : {joke}");
            }
            catch
            {
                await LogHandlerService.LogUserActionAsync(Context, "Failed to perform Allar Joke");

                await Context.RespondAsync($"{Context.User.Mention}: Failed to fetch joke. Please contact an Administrator.");
            }
        }
Пример #2
0
        public async Task FetchMommaJoke(CommandContext Context)
        {
            await LogHandlerService.LogUserActionAsync(Context, "Invoked mom joke.");

            if (!await DiscordHelpers.AttemptChargeDallarForCommand(Context, 1))
            {
                await LogHandlerService.LogUserActionAsync(Context, "Failed charged for mom Joke");

                return;
            }

            await LogHandlerService.LogUserActionAsync(Context, "Successfully charged for mom Joke");

            await Context.TriggerTypingAsync();

            await Context.RespondAsync($"{Context.User.Mention}: {Program.YoMommaJokes.GetRandomYoMommaJoke()}");
        }
Пример #3
0
        public async Task FetchDadJoke(CommandContext Context)
        {
            await LogHandlerService.LogUserActionAsync(Context, "Invoked Dad Joke");

            if (!await DiscordHelpers.AttemptChargeDallarForCommand(Context, 1))
            {
                await LogHandlerService.LogUserActionAsync(Context, "Failed charged for dad Joke");

                return;
            }

            await LogHandlerService.LogUserActionAsync(Context, "Successfully charged for dad Joke");

            await Context.TriggerTypingAsync();

            var client = new WebClient();

            client.Headers.Add("Accept", "text/plain");

            var joke = await client.DownloadStringTaskAsync("https://icanhazdadjoke.com/");

            await Context.RespondAsync($"{Context.User.Mention} : {joke}");
        }