youtube, welcome messages and futher code improvements

This commit is contained in:
dboerlage 2017-04-17 12:55:20 +02:00
parent 8d838eaae1
commit 59d0a5e135
No known key found for this signature in database
GPG key ID: BDA07B7D3FCF147F
7 changed files with 132 additions and 12 deletions

View file

@ -21,12 +21,26 @@ namespace Geekbot.net.Modules
var messages = (int)redis.StringGet(key);
var level = GetLevelAtExperience(messages);
await ReplyAsync($"```\r\n" +
$"{userInfo.Username}#{userInfo.Discriminator}\r\n" +
$"Messages Sent: {messages}\r\n" +
$"Level: {level}\r\n" +
$"Discordian Since: {userInfo.CreatedAt.Day}/{userInfo.CreatedAt.Month}/{userInfo.CreatedAt.Year} ({age} days)" +
$"```");
var reply = "";
if (Context.Message.Author.Id == userInfo.Id)
{
reply = reply + $"here are your stats {userInfo.Mention}\r\n";
}
else
{
reply = reply + $"here are {userInfo.Mention}'s stats\r\n";
}
reply = reply + $"```\r\n";
reply = reply + $"Level: {level}\r\n";
reply = reply + $"Messages Sent: {messages}\r\n";
reply =
reply +
$"Discordian Since: {userInfo.CreatedAt.Day}/{userInfo.CreatedAt.Month}/{userInfo.CreatedAt.Year} ({age} days)";
reply = reply + $"```";
await ReplyAsync(reply);
}
[Command("level"), Summary("Get a level based on a number")]

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Discord.Commands;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
namespace Geekbot.net.Modules
{
public class Youtube : ModuleBase
{
[Command("yt"), Summary("Search for something on youtube.")]
public async Task Yt([Remainder, Summary("A Song Title")] string searchQuery)
{
// AIzaSyDQoJvtNXPVwIcUbSeeDEchnA4a-q1go0E
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "AIzaSyDQoJvtNXPVwIcUbSeeDEchnA4a-q1go0E",
ApplicationName = this.GetType().ToString()
});
var searchListRequest = youtubeService.Search.List("snippet");
searchListRequest.Q = searchQuery; // Replace with your search term.
searchListRequest.MaxResults = 50;
// Call the search.list method to retrieve results matching the specified query term.
var searchListResponse = await searchListRequest.ExecuteAsync();
var result = searchListResponse.Items[0];
await ReplyAsync($"'{result.Snippet.Title}' from '{result.Snippet.ChannelTitle}' https://youtu.be/{result.Id.VideoId}");
}
}
}