Temporarily disable the youtube command

This commit is contained in:
Daan Boerlage 2022-07-22 18:33:56 +02:00
parent 29f44c34bc
commit 94bdc1081b
Signed by: daan
GPG key ID: FCE070E1E4956606

View file

@ -1,59 +1,59 @@
using System; using Discord.Commands;
using System.Threading.Tasks;
using Discord.Commands;
using Geekbot.Core; using Geekbot.Core;
using Geekbot.Core.ErrorHandling; // using Geekbot.Core.ErrorHandling;
using Geekbot.Core.GlobalSettings; // using Geekbot.Core.GlobalSettings;
using Google.Apis.Services; // using Google.Apis.Services;
using Google.Apis.YouTube.v3; // using Google.Apis.YouTube.v3;
namespace Geekbot.Bot.Commands.Integrations namespace Geekbot.Bot.Commands.Integrations
{ {
public class Youtube : TransactionModuleBase public class Youtube : TransactionModuleBase
{ {
private readonly IGlobalSettings _globalSettings; // private readonly IGlobalSettings _globalSettings;
private readonly IErrorHandler _errorHandler; // private readonly IErrorHandler _errorHandler;
public Youtube(IGlobalSettings globalSettings, IErrorHandler errorHandler) // public Youtube(IGlobalSettings globalSettings, IErrorHandler errorHandler)
{ // {
_globalSettings = globalSettings; // _globalSettings = globalSettings;
_errorHandler = errorHandler; // _errorHandler = errorHandler;
} // }
[Command("yt", RunMode = RunMode.Async)] [Command("yt", RunMode = RunMode.Async)]
[Summary("Search for something on youtube.")] [Summary("Search for something on youtube.")]
public async Task Yt([Remainder] [Summary("title")] string searchQuery) public async Task Yt([Remainder] [Summary("title")] string searchQuery)
{ {
var key = _globalSettings.GetKey("YoutubeKey"); await ReplyAsync("The youtube command is temporarily disabled");
if (string.IsNullOrEmpty(key))
{
await ReplyAsync("No youtube key set, please tell my senpai to set one");
return;
}
try // var key = _globalSettings.GetKey("YoutubeKey");
{ // if (string.IsNullOrEmpty(key))
var youtubeService = new YouTubeService(new BaseClientService.Initializer // {
{ // await ReplyAsync("No youtube key set, please tell my senpai to set one");
ApiKey = key, // return;
ApplicationName = GetType().ToString() // }
}); //
// try
var searchListRequest = youtubeService.Search.List("snippet"); // {
searchListRequest.Q = searchQuery; // var youtubeService = new YouTubeService(new BaseClientService.Initializer
searchListRequest.MaxResults = 2; // {
// ApiKey = key,
var searchListResponse = await searchListRequest.ExecuteAsync(); // ApplicationName = GetType().ToString()
// });
var result = searchListResponse.Items[0]; //
// var searchListRequest = youtubeService.Search.List("snippet");
await ReplyAsync( // searchListRequest.Q = searchQuery;
$"\"{result.Snippet.Title}\" from \"{result.Snippet.ChannelTitle}\" https://youtu.be/{result.Id.VideoId}"); // searchListRequest.MaxResults = 2;
} //
catch (Exception e) // var searchListResponse = await searchListRequest.ExecuteAsync();
{ //
await _errorHandler.HandleCommandException(e, Context); // var result = searchListResponse.Items[0];
} //
// await ReplyAsync(
// $"\"{result.Snippet.Title}\" from \"{result.Snippet.ChannelTitle}\" https://youtu.be/{result.Id.VideoId}");
// }
// catch (Exception e)
// {
// await _errorHandler.HandleCommandException(e, Context);
// }
} }
} }
} }