Merge remote-tracking branch 'refs/remotes/Kwoth/1.0' into math
# Conflicts: # src/NadekoBot/project.json # src/NadekoBot/project.lock.json
This commit is contained in:
@@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Restart(IMessage imsg)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// await channel.SendMessageAsync("`Restarting in 2 seconds...`");
|
||||
// await Task.Delay(2000);
|
||||
@@ -42,7 +42,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequirePermission(GuildPermission.ManageGuild)]
|
||||
//public async Task Delmsgoncmd(IMessage imsg)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// var conf = SpecificConfigurations.Default.Of(channel.Guild.Id);
|
||||
// conf.AutoDeleteMessagesOnCommand = !conf.AutoDeleteMessagesOnCommand;
|
||||
@@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageRoles)]
|
||||
public async Task Setrole(IMessage imsg, IGuildUser usr, [Remainder] IRole role)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
try
|
||||
{
|
||||
await usr.AddRolesAsync(role).ConfigureAwait(false);
|
||||
@@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageRoles)]
|
||||
public async Task Removerole(IMessage imsg, IGuildUser usr, [Remainder] IRole role)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
try
|
||||
{
|
||||
await usr.RemoveRolesAsync(role).ConfigureAwait(false);
|
||||
@@ -93,7 +93,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageRoles)]
|
||||
public async Task RenameRole(IMessage imsg, IRole roleToEdit, string newname)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
try
|
||||
{
|
||||
if (roleToEdit.Position > (await channel.Guild.GetCurrentUserAsync().ConfigureAwait(false)).Roles.Max(r => r.Position))
|
||||
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageRoles)]
|
||||
public async Task RemoveAllRoles(IMessage imsg, [Remainder] IGuildUser user)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -133,7 +133,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageRoles)]
|
||||
public async Task CreateRole(IMessage imsg, [Remainder] string roleName = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(roleName))
|
||||
@@ -154,7 +154,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageRoles)]
|
||||
public async Task RoleColor(IMessage imsg, params string[] args)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (args.Count() != 2 && args.Count() != 4)
|
||||
{
|
||||
@@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.BanMembers)]
|
||||
public async Task Ban(IMessage imsg, IGuildUser user)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var msg = "";
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.BanMembers)]
|
||||
public async Task Softban(IMessage imsg, IGuildUser user, [Remainder] string msg = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(msg))
|
||||
{
|
||||
@@ -244,7 +244,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Kick(IMessage imsg, IGuildUser user, [Remainder] string msg = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
@@ -273,7 +273,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.MuteMembers)]
|
||||
public async Task Mute(IMessage imsg, params IGuildUser[] users)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!users.Any())
|
||||
return;
|
||||
@@ -296,7 +296,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.MuteMembers)]
|
||||
public async Task Unmute(IMessage imsg, params IGuildUser[] users)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!users.Any())
|
||||
return;
|
||||
@@ -319,7 +319,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.DeafenMembers)]
|
||||
public async Task Deafen(IMessage imsg, params IGuildUser[] users)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!users.Any())
|
||||
return;
|
||||
@@ -342,7 +342,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.DeafenMembers)]
|
||||
public async Task UnDeafen(IMessage imsg, params IGuildUser[] users)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!users.Any())
|
||||
return;
|
||||
@@ -374,7 +374,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageChannels)]
|
||||
public async Task CreatVoiChanl(IMessage imsg, [Remainder] string channelName)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
//todo actually print info about created channel
|
||||
await channel.Guild.CreateVoiceChannelAsync(channelName).ConfigureAwait(false);
|
||||
await channel.SendMessageAsync($"Created voice channel **{channelName}**.").ConfigureAwait(false);
|
||||
@@ -394,7 +394,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageChannels)]
|
||||
public async Task CreaTxtChanl(IMessage imsg, [Remainder] string channelName)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
//todo actually print info about created channel
|
||||
var txtCh = await channel.Guild.CreateTextChannelAsync(channelName).ConfigureAwait(false);
|
||||
await channel.SendMessageAsync($"Added text channel **{channelName}**.").ConfigureAwait(false);
|
||||
@@ -405,7 +405,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageChannels)]
|
||||
public async Task SetTopic(IMessage imsg, [Remainder] string topic = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
topic = topic ?? "";
|
||||
await (channel as ITextChannel).ModifyAsync(c => c.Topic = topic);
|
||||
//await (channel).ModifyAsync(c => c).ConfigureAwait(false);
|
||||
@@ -417,7 +417,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.ManageChannels)]
|
||||
public async Task SetChanlName(IMessage imsg, [Remainder] string name)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.ModifyAsync(c => c.Name = name).ConfigureAwait(false);
|
||||
await channel.SendMessageAsync(":ok: **New channel name set.**").ConfigureAwait(false);
|
||||
@@ -429,7 +429,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Prune(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var user = await channel.Guild.GetCurrentUserAsync();
|
||||
|
||||
@@ -471,7 +471,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Die(IMessage imsg)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// await channel.SendMessageAsync("`Shutting down.`").ConfigureAwait(false);
|
||||
// await Task.Delay(2000).ConfigureAwait(false);
|
||||
@@ -483,7 +483,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Setname(IMessage imsg, [Remainder] string newName = null)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
//}
|
||||
|
||||
@@ -492,12 +492,12 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task NewAvatar(IMessage imsg, [Remainder] string img = null)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(e.GetArg("img")))
|
||||
// if (string.IsNullOrWhiteSpace(img))
|
||||
// return;
|
||||
// // Gather user provided URL.
|
||||
// var avatarAddress = e.GetArg("img");
|
||||
// var avatarAddress = img;
|
||||
// var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
|
||||
// var image = System.Drawing.Image.FromStream(imageStream);
|
||||
// await client.CurrentUser.Edit("", avatar: image.ToStream()).ConfigureAwait(false);
|
||||
@@ -511,11 +511,11 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task SetGame(IMessage imsg, [Remainder] string game = null)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// game = game ?? "";
|
||||
|
||||
// client.SetGame(e.GetArg("set_game"));
|
||||
// client.SetGame(set_game);
|
||||
//}
|
||||
|
||||
////todo owner only
|
||||
@@ -523,7 +523,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Send(IMessage imsg, string where, [Remainder] string msg = null)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(msg))
|
||||
// return;
|
||||
@@ -569,9 +569,9 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Donadd(IMessage imsg, IUser donator, int amount)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var donator = channel.Guild.FindUsers(e.GetArg("donator")).FirstOrDefault();
|
||||
// var amount = int.Parse(e.GetArg("amount"));
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
// var donator = channel.Guild.FindUsers(donator).FirstOrDefault();
|
||||
// var amount = int.Parse(amount);
|
||||
// if (donator == null) return;
|
||||
// try
|
||||
// {
|
||||
@@ -592,7 +592,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Announce(IMessage imsg, [Remainder] string message)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// foreach (var ch in (await _client.GetGuildsAsync().ConfigureAwait(false)).Select(async g => await g.GetDefaultChannelAsync().ConfigureAwait(false)))
|
||||
// {
|
||||
@@ -607,7 +607,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task SaveChat(IMessage imsg, int cnt)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// ulong? lastmsgId = null;
|
||||
// var sb = new StringBuilder();
|
||||
@@ -640,7 +640,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequirePermission(GuildPermission.MentionEveryone)]
|
||||
public async Task MentionRole(IMessage imsg, params IRole[] roles)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
string send = $"--{imsg.Author.Mention} has invoked a mention on the following roles--";
|
||||
foreach (var role in roles)
|
||||
@@ -665,7 +665,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Donators(IMessage imsg)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// var rows = DbHandler.Instance.GetAllRows<Donator>();
|
||||
// var donatorsOrdered = rows.OrderByDescending(d => d.Amount);
|
||||
|
@@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//[RequirePermission(GuildPermission.ManageRoles)]
|
||||
//public async Task AutoAssignRole(IMessage imsg, IRole role)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||
|
||||
|
@@ -86,7 +86,7 @@
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// int token;
|
||||
// if (!int.TryParse(e.GetArg("token"), out token))
|
||||
// if (!int.TryParse(token, out token))
|
||||
// return;
|
||||
// HashSet<Channel> set;
|
||||
// if (!Subscribers.TryGetValue(token, out set))
|
||||
|
@@ -456,7 +456,7 @@
|
||||
// {
|
||||
|
||||
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||
// if (e.GetArg("all")?.ToLower() == "all")
|
||||
// if (all?.ToLower() == "all")
|
||||
// {
|
||||
// foreach (var voiceChannel in e.Server.VoiceChannels)
|
||||
// {
|
||||
|
@@ -80,8 +80,8 @@
|
||||
// .AddCheck(SimpleCheckers.ManageMessages())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var minutesStr = e.GetArg("minutes");
|
||||
// var msg = e.GetArg("msg");
|
||||
// var minutesStr = minutes;
|
||||
// var msg = msg;
|
||||
|
||||
// // if both null, disable
|
||||
// if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
||||
|
@@ -109,7 +109,7 @@
|
||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var arg = e.GetArg("text");
|
||||
// var arg = text;
|
||||
// if (string.IsNullOrWhiteSpace(arg))
|
||||
// return;
|
||||
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||
@@ -149,7 +149,7 @@
|
||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var arg = e.GetArg("number");
|
||||
// var arg = number;
|
||||
// int num;
|
||||
// string str;
|
||||
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||
|
@@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
_client.MessageReceived += async (imsg) =>
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (channel == null || await imsg.IsAuthor())
|
||||
return;
|
||||
@@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Slowmode(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
ConcurrentDictionary<ulong, DateTime> throwaway;
|
||||
if (RatelimitingChannels.TryRemove(channel.Id, out throwaway))
|
||||
|
@@ -49,7 +49,7 @@
|
||||
// .AddCheck(SimpleCheckers.CanManageRoles)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var roleName = e.GetArg("role")?.Trim();
|
||||
// var roleName = role?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(roleName))
|
||||
// return;
|
||||
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
@@ -116,7 +116,7 @@
|
||||
// .Parameter("role", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var roleName = e.GetArg("role")?.Trim();
|
||||
// var roleName = role?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(roleName))
|
||||
// return;
|
||||
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
@@ -172,7 +172,7 @@
|
||||
// .Parameter("role", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var roleName = e.GetArg("role")?.Trim();
|
||||
// var roleName = role?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(roleName))
|
||||
// return;
|
||||
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
|
@@ -24,7 +24,7 @@
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Leave(IMessage imsg, [Remainder] string guildStr)
|
||||
// {
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// guildStr = guildStr.ToUpperInvariant();
|
||||
// var server = _client.GetGuilds().FirstOrDefault(g => g.Id.ToString() == guildStr) ?? _client.GetGuilds().FirstOrDefault(g => g.Name.ToUpperInvariant() == guildStr);
|
||||
|
@@ -240,14 +240,14 @@
|
||||
// {
|
||||
// if (!imsg.Author.ServerPermissions.ManageServer) return;
|
||||
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
||||
// if (string.IsNullOrWhiteSpace(msg))
|
||||
// {
|
||||
// await channel.SendMessageAsync("`Current greet message:` " + ann.GreetText);
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// ann.GreetText = e.GetArg("msg");
|
||||
// ann.GreetText = msg;
|
||||
// await channel.SendMessageAsync("New greet message set.").ConfigureAwait(false);
|
||||
// if (!ann.Greet)
|
||||
// await channel.SendMessageAsync("Enable greet messsages by typing `.greet`").ConfigureAwait(false);
|
||||
@@ -273,13 +273,13 @@
|
||||
// {
|
||||
// if (!imsg.Author.ServerPermissions.ManageServer) return;
|
||||
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
||||
// if (string.IsNullOrWhiteSpace(msg))
|
||||
// {
|
||||
// await channel.SendMessageAsync("`Current bye message:` " + ann.ByeText);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// ann.ByeText = e.GetArg("msg");
|
||||
// ann.ByeText = msg;
|
||||
// await channel.SendMessageAsync("New bye message set.").ConfigureAwait(false);
|
||||
// if (!ann.Bye)
|
||||
// await channel.SendMessageAsync("Enable bye messsages by typing `.bye`.").ConfigureAwait(false);
|
||||
|
@@ -40,7 +40,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task CreateWar(IMessage imsg, int size, [Remainder] string enemyClan = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
||||
return;
|
||||
@@ -73,7 +73,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task StartWar(IMessage imsg, [Remainder] string number = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
int num = 0;
|
||||
int.TryParse(number, out num);
|
||||
@@ -100,7 +100,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ListWar(IMessage imsg, [Remainder] string number = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// if number is null, print all wars in a short way
|
||||
if (string.IsNullOrWhiteSpace(number))
|
||||
@@ -143,7 +143,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Claim(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var warsInfo = GetWarInfo(imsg, number);
|
||||
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ClaimFinish1(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
await FinishClaim(imsg, number, baseNumber, other_name, 1);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ClaimFinish2(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
await FinishClaim(imsg, number, baseNumber, other_name, 2);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ClaimFinish(IMessage imsg, int number, int baseNumber, [Remainder] string other_name = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
await FinishClaim(imsg, number, baseNumber, other_name);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task EndWar(IMessage imsg, int number)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var warsInfo = GetWarInfo(imsg,number);
|
||||
if (warsInfo == null)
|
||||
@@ -213,7 +213,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Unclaim(IMessage imsg, int number, [Remainder] string otherName = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var warsInfo = GetWarInfo(imsg, number);
|
||||
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||
@@ -239,7 +239,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
|
||||
private async Task FinishClaim(IMessage imsg, int number, int baseNumber, [Remainder] string other_name, int stars = 3)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var warInfo = GetWarInfo(imsg, number);
|
||||
if (warInfo == null || warInfo.Item1.Count == 0)
|
||||
{
|
||||
@@ -265,7 +265,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
|
||||
private static Tuple<List<ClashWar>, int> GetWarInfo(IMessage imsg, int num)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
//check if there are any wars
|
||||
List<ClashWar> wars = null;
|
||||
ClashWars.TryGetValue(channel.Guild.Id, out wars);
|
||||
|
@@ -23,7 +23,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Race(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var ar = new AnimalRace(channel.Guild.Id, channel);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task JoinRace(IMessage imsg, int amount = 0)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (amount < 0)
|
||||
amount = 0;
|
||||
|
@@ -26,7 +26,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
// InternalRoll(imsg, arg, false);
|
||||
|
||||
//private async Task InternalRoll(IMessage imsg, string arg, bool ordered) {
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
// var r = new Random();
|
||||
// if (string.IsNullOrWhiteSpace(arg))
|
||||
// {
|
||||
@@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task NRoll(IMessage imsg, [Remainder] string range)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
|
||||
try
|
||||
|
@@ -53,7 +53,7 @@
|
||||
// try
|
||||
// {
|
||||
// var num = 1;
|
||||
// var isParsed = int.TryParse(e.GetArg("count"), out num);
|
||||
// var isParsed = int.TryParse(count, out num);
|
||||
// if (!isParsed || num < 2)
|
||||
// {
|
||||
// var c = cards.DrawACard();
|
||||
|
@@ -34,9 +34,9 @@
|
||||
// public Func<CommandEventArgs, Task> BetFlipCoinFunc() => async e =>
|
||||
// {
|
||||
|
||||
// var amountstr = e.GetArg("amount").Trim();
|
||||
// var amountstr = amount.Trim();
|
||||
|
||||
// var guessStr = e.GetArg("guess").Trim().ToUpperInvariant();
|
||||
// var guessStr = guess.Trim().ToUpperInvariant();
|
||||
// if (guessStr != "H" && guessStr != "T" && guessStr != "HEADS" && guessStr != "TAILS")
|
||||
// return;
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
// public Func<CommandEventArgs, Task> FlipCoinFunc() => async e =>
|
||||
// {
|
||||
|
||||
// if (e.GetArg("count") == "")
|
||||
// if (count == "")
|
||||
// {
|
||||
// if (rng.Next(0, 2) == 1)
|
||||
// await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||
@@ -92,7 +92,7 @@
|
||||
// else
|
||||
// {
|
||||
// int result;
|
||||
// if (int.TryParse(e.GetArg("count"), out result))
|
||||
// if (int.TryParse(count, out result))
|
||||
// {
|
||||
// if (result > 10)
|
||||
// result = 10;
|
||||
|
@@ -23,7 +23,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Raffle(IMessage imsg, [Remainder] IRole role = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
role = role ?? channel.Guild.EveryoneRole;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Cash(IMessage imsg, [Remainder] string arg)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// var usr = e.Message.MentionedUsers.FirstOrDefault() ?? imsg.Author;
|
||||
// var pts = GetUserFlowers(usr.Id);
|
||||
@@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Give(IMessage imsg, long amount, [Remainder] IUser receiver)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
// if (amount <= 0)
|
||||
// return;
|
||||
// var userFlowers = GetUserFlowers(imsg.Author.Id);
|
||||
@@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Award(IMessage imsg, long amount, [Remainder] ulong usrId)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// if (amount <= 0)
|
||||
// return;
|
||||
@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Take(IMessage imsg, long amount, [Remainder] ulong usrId)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
// if (amount <= 0)
|
||||
// return;
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task BetRoll(IMessage imsg, int amount)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// if (amount < 1)
|
||||
// return;
|
||||
@@ -160,7 +160,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Leaderboard(IMessage imsg)
|
||||
// {
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// var richestTemp = DbHandler.Instance.GetTopRichest();
|
||||
// var richest = richestTemp as CurrencyState[] ?? richestTemp.ToArray();
|
||||
|
@@ -16,7 +16,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Leet(IMessage imsg, int level, [Remainder] string text = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
text = text.Trim();
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
|
@@ -131,7 +131,7 @@
|
||||
// .Parameter("cd", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var cdStr = e.GetArg("cd");
|
||||
// var cdStr = cd;
|
||||
// int cd = 2;
|
||||
// if (!int.TryParse(cdStr, out cd) || cd < 0)
|
||||
// {
|
||||
|
@@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Poll(IMessage imsg, [Remainder] string arg = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
||||
return;
|
||||
@@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Pollend(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!(imsg.Author as IGuildUser).GuildPermissions.ManageChannels)
|
||||
return;
|
||||
|
@@ -181,11 +181,11 @@
|
||||
// .Parameter("text", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (!NadekoBot.IsOwner(imsg.Author.Id) || string.IsNullOrWhiteSpace(e.GetArg("text"))) return;
|
||||
// if (!NadekoBot.IsOwner(imsg.Author.Id) || string.IsNullOrWhiteSpace(text)) return;
|
||||
|
||||
// DbHandler.Instance.Connection.Insert(new TypingArticle
|
||||
// {
|
||||
// Text = e.GetArg("text"),
|
||||
// Text = text,
|
||||
// DateAdded = DateTime.Now
|
||||
// });
|
||||
|
||||
|
@@ -21,7 +21,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Trivia(IMessage imsg, string[] args)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
TriviaGame trivia;
|
||||
if (!RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
|
||||
@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Tl(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
TriviaGame trivia;
|
||||
if (RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
|
||||
@@ -61,7 +61,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Tq(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
TriviaGame trivia;
|
||||
if (RunningTrivias.TryRemove(channel.Guild.Id, out trivia))
|
||||
|
@@ -25,7 +25,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Choose(IMessage imsg, [Remainder] string list = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
if (string.IsNullOrWhiteSpace(list))
|
||||
return;
|
||||
var listArr = list.Split(';');
|
||||
@@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task _8Ball(IMessage imsg, [Remainder] string question = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(question))
|
||||
return;
|
||||
@@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Rps(IMessage imsg, string input)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
Func<int,string> GetRPSPick = (p) =>
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Linux(IMessage imsg, string guhnoo, string loonix)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync(
|
||||
$@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
|
||||
|
@@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Help
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Modules(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync("`List of modules:` \n• " + string.Join("\n• ", _commands.Modules.Select(m => m.Name)) + $"\n`Type \"-commands module_name\" to get a list of commands in that module.`")
|
||||
.ConfigureAwait(false);
|
||||
@@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Help
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Commands(IMessage imsg, [Remainder] string module = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
module = module?.Trim().ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(module))
|
||||
@@ -69,7 +69,7 @@ namespace NadekoBot.Modules.Help
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task H(IMessage imsg, [Remainder] string comToFind = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
comToFind = comToFind?.ToLowerInvariant();
|
||||
if (string.IsNullOrWhiteSpace(comToFind))
|
||||
@@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Help
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Guide(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync(
|
||||
@"**LIST OF COMMANDS**: <http://nadekobot.readthedocs.io/en/latest/Commands%20List/>
|
||||
@@ -128,7 +128,7 @@ namespace NadekoBot.Modules.Help
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Donate(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync(
|
||||
$@"You can support the project on patreon. <https://patreon.com/nadekobot> or
|
||||
|
724
src/NadekoBot/Modules/Music/Music.cs
Normal file
724
src/NadekoBot/Modules/Music/Music.cs
Normal file
@@ -0,0 +1,724 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules.Music.Classes;
|
||||
using System.Collections.Concurrent;
|
||||
using Discord.WebSocket;
|
||||
using NadekoBot.Services;
|
||||
using System.IO;
|
||||
using Discord;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Attributes;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Net.Http;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Modules.Music
|
||||
{
|
||||
[Module("!!", AppendSpace = false)]
|
||||
public partial class Music : DiscordModule
|
||||
{
|
||||
public static ConcurrentDictionary<ulong, MusicPlayer> MusicPlayers = new ConcurrentDictionary<ulong, MusicPlayer>();
|
||||
|
||||
public const string MusicDataPath = "data/musicdata";
|
||||
private IGoogleApiService _google;
|
||||
|
||||
public Music(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client, IGoogleApiService google) : base(loc, cmds, config, client)
|
||||
{
|
||||
//it can fail if its currenctly opened or doesn't exist. Either way i don't care
|
||||
try { Directory.Delete(MusicDataPath, true); } catch { }
|
||||
|
||||
Directory.CreateDirectory(MusicDataPath);
|
||||
|
||||
_google = google;
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Next(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return;
|
||||
if (musicPlayer.PlaybackVoiceChannel == ((IGuildUser)imsg.Author).VoiceChannel)
|
||||
musicPlayer.Next();
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Stop(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel == musicPlayer.PlaybackVoiceChannel)
|
||||
{
|
||||
musicPlayer.Autoplay = false;
|
||||
musicPlayer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Destroy(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryRemove(channel.Guild.Id, out musicPlayer)) return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel == musicPlayer.PlaybackVoiceChannel)
|
||||
musicPlayer.Destroy();
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Pause(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
musicPlayer.TogglePause();
|
||||
if (musicPlayer.Paused)
|
||||
await channel.SendMessageAsync("🎵`Music Player paused.`").ConfigureAwait(false);
|
||||
else
|
||||
await channel.SendMessageAsync("🎵`Music Player unpaused.`").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Queue(IMessage imsg, [Remainder] string query)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await QueueSong(((IGuildUser)imsg.Author), channel, ((IGuildUser)imsg.Author).VoiceChannel, query).ConfigureAwait(false);
|
||||
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
||||
{
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
await imsg.DeleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task SoundCloudQueue(IMessage imsg, [Remainder] string query)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await QueueSong(((IGuildUser)imsg.Author), channel, ((IGuildUser)imsg.Author).VoiceChannel, query, musicType: MusicType.Soundcloud).ConfigureAwait(false);
|
||||
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
||||
{
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
await imsg.DeleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ListQueue(IMessage imsg, int page = 1)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
{
|
||||
await channel.SendMessageAsync("🎵 No active music player.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (page <= 0)
|
||||
return;
|
||||
|
||||
var currentSong = musicPlayer.CurrentSong;
|
||||
if (currentSong == null)
|
||||
return;
|
||||
var toSend = $"🎵`Now Playing` {currentSong.PrettyName} " + $"{currentSong.PrettyCurrentTime()}\n";
|
||||
if (musicPlayer.RepeatSong)
|
||||
toSend += "🔂";
|
||||
else if (musicPlayer.RepeatPlaylist)
|
||||
toSend += "🔁";
|
||||
toSend += $" **{musicPlayer.Playlist.Count}** `tracks currently queued. Showing page {page}` ";
|
||||
if (musicPlayer.MaxQueueSize != 0 && musicPlayer.Playlist.Count >= musicPlayer.MaxQueueSize)
|
||||
toSend += "**Song queue is full!**\n";
|
||||
else
|
||||
toSend += "\n";
|
||||
const int itemsPerPage = 15;
|
||||
int startAt = itemsPerPage * (page - 1);
|
||||
var number = 1 + startAt;
|
||||
await channel.SendMessageAsync(toSend + string.Join("\n", musicPlayer.Playlist.Skip(startAt).Take(15).Select(v => $"`{number++}.` {v.PrettyName}"))).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task NowPlaying(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
var currentSong = musicPlayer.CurrentSong;
|
||||
if (currentSong == null)
|
||||
return;
|
||||
await channel.SendMessageAsync($"🎵`Now Playing` {currentSong.PrettyName} " +
|
||||
$"{currentSong.PrettyCurrentTime()}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Volume(IMessage imsg, int val)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
if (val < 0)
|
||||
return;
|
||||
var volume = musicPlayer.SetVolume(val);
|
||||
await channel.SendMessageAsync($"🎵 `Volume set to {volume}%`").ConfigureAwait(false);
|
||||
}
|
||||
////todo DB
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Defvol(IMessage imsg, [Remainder] int val)
|
||||
//{
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
// var arg = val;
|
||||
// float volume;
|
||||
// if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100)
|
||||
// {
|
||||
// await channel.SendMessageAsync("Volume number invalid.").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// var conf = SpecificConfigurations.Default.Of(channel.Guild.Id);
|
||||
// conf.DefaultMusicVolume = volume / 100;
|
||||
// await channel.SendMessageAsync($"🎵 `Default volume set to {volume}%`").ConfigureAwait(false);
|
||||
//}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Mute(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
musicPlayer.SetVolume(0);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Max(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
musicPlayer.SetVolume(100);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Shuffle(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
if (musicPlayer.Playlist.Count < 2)
|
||||
{
|
||||
await channel.SendMessageAsync("💢 Not enough songs in order to perform the shuffle.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
musicPlayer.Shuffle();
|
||||
await channel.SendMessageAsync("🎵 `Songs shuffled.`").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Playlist(IMessage imsg, [Remainder] string playlist)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var arg = playlist;
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel?.Guild != channel.Guild)
|
||||
{
|
||||
await channel.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var plId = (await _google.GetPlaylistIdsByKeywordsAsync(arg).ConfigureAwait(false)).FirstOrDefault();
|
||||
if (plId == null)
|
||||
{
|
||||
await channel.SendMessageAsync("No search results for that query.");
|
||||
return;
|
||||
}
|
||||
var ids = await _google.GetPlaylistTracksAsync(plId, 500).ConfigureAwait(false);
|
||||
if (!ids.Any())
|
||||
{
|
||||
await channel.SendMessageAsync($"🎵 `Failed to find any songs.`").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var idArray = ids as string[] ?? ids.ToArray();
|
||||
var count = idArray.Length;
|
||||
var msg =
|
||||
await channel.SendMessageAsync($"🎵 `Attempting to queue {count} songs".SnPl(count) + "...`").ConfigureAwait(false);
|
||||
foreach (var id in idArray)
|
||||
{
|
||||
try
|
||||
{
|
||||
await QueueSong(((IGuildUser)imsg.Author), channel, ((IGuildUser)imsg.Author).VoiceChannel, id, true).ConfigureAwait(false);
|
||||
}
|
||||
catch (PlaylistFullException)
|
||||
{ break; }
|
||||
catch { }
|
||||
}
|
||||
await msg.ModifyAsync(m => m.Content = "🎵 `Playlist queue complete.`").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task SoundCloudPl(IMessage imsg, [Remainder] string pl)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
pl = pl?.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(pl))
|
||||
return;
|
||||
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var scvids = JObject.Parse(await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={pl}&client_id={NadekoBot.Credentials.SoundCloudClientId}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
|
||||
await QueueSong(((IGuildUser)imsg.Author), channel, ((IGuildUser)imsg.Author).VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false);
|
||||
|
||||
MusicPlayer mp;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out mp))
|
||||
return;
|
||||
|
||||
foreach (var svideo in scvids.Skip(1))
|
||||
{
|
||||
try
|
||||
{
|
||||
mp.AddSong(new Song(new Classes.SongInfo
|
||||
{
|
||||
Title = svideo.FullName,
|
||||
Provider = "SoundCloud",
|
||||
Uri = svideo.StreamLink,
|
||||
ProviderType = MusicType.Normal,
|
||||
Query = svideo.TrackLink,
|
||||
}), ((IGuildUser)imsg.Author).Username);
|
||||
}
|
||||
catch (PlaylistFullException) { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task LocalPl(IMessage imsg, [Remainder] string directory)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var arg = directory;
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
return;
|
||||
try
|
||||
{
|
||||
var fileEnum = new DirectoryInfo(arg).GetFiles()
|
||||
.Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System));
|
||||
foreach (var file in fileEnum)
|
||||
{
|
||||
try
|
||||
{
|
||||
await QueueSong(((IGuildUser)imsg.Author), channel, ((IGuildUser)imsg.Author).VoiceChannel, file.FullName, true, MusicType.Local).ConfigureAwait(false);
|
||||
}
|
||||
catch (PlaylistFullException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
await channel.SendMessageAsync("🎵 `Directory queue complete.`").ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Radio(IMessage imsg, string radio_link)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel?.Guild != channel.Guild)
|
||||
{
|
||||
await channel.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await QueueSong(((IGuildUser)imsg.Author), channel, ((IGuildUser)imsg.Author).VoiceChannel, radio_link, musicType: MusicType.Radio).ConfigureAwait(false);
|
||||
if (channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
|
||||
{
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
await imsg.DeleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Local(IMessage imsg, [Remainder] string path)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var arg = path;
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
return;
|
||||
await QueueSong(((IGuildUser)imsg.Author), channel, ((IGuildUser)imsg.Author).VoiceChannel, path, musicType: MusicType.Local).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Move(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
var voiceChannel = ((IGuildUser)imsg.Author).VoiceChannel;
|
||||
if (voiceChannel == null || voiceChannel.Guild != channel.Guild || !MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
musicPlayer.MoveToVoiceChannel(voiceChannel);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Remove(IMessage imsg, int num)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
if (num <= 0 || num > musicPlayer.Playlist.Count)
|
||||
return;
|
||||
var song = (musicPlayer.Playlist as List<Song>)?[num - 1];
|
||||
musicPlayer.RemoveSongAt(num - 1);
|
||||
await channel.SendMessageAsync($"🎵**Track {song.PrettyName} at position `#{num}` has been removed.**").ConfigureAwait(false);
|
||||
}
|
||||
//todo fix
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Remove(IMessage imsg, string all)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (all.Trim().ToUpperInvariant() != "ALL")
|
||||
return;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return;
|
||||
musicPlayer.ClearQueue();
|
||||
await channel.SendMessageAsync($"🎵`Queue cleared!`").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task MoveSong(IMessage imsg, [Remainder] string fromto)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
fromto = fromto?.Trim();
|
||||
var fromtoArr = fromto.Split('>');
|
||||
|
||||
int n1;
|
||||
int n2;
|
||||
|
||||
var playlist = musicPlayer.Playlist as List<Song> ?? musicPlayer.Playlist.ToList();
|
||||
|
||||
if (fromtoArr.Length != 2 || !int.TryParse(fromtoArr[0], out n1) ||
|
||||
!int.TryParse(fromtoArr[1], out n2) || n1 < 1 || n2 < 1 || n1 == n2 ||
|
||||
n1 > playlist.Count || n2 > playlist.Count)
|
||||
{
|
||||
await channel.SendMessageAsync("`Invalid input.`").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var s = playlist[n1 - 1];
|
||||
playlist.Insert(n2 - 1, s);
|
||||
var nn1 = n2 < n1 ? n1 : n1 - 1;
|
||||
playlist.RemoveAt(nn1);
|
||||
|
||||
await channel.SendMessageAsync($"🎵`Moved` {s.PrettyName} `from #{n1} to #{n2}`").ConfigureAwait(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task SetMaxQueue(IMessage imsg, uint size)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
musicPlayer.MaxQueueSize = size;
|
||||
await channel.SendMessageAsync($"🎵 `Max queue set to {(size == 0 ? ("unlimited") : size + " tracks")}`");
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ReptCurSong(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
var currentSong = musicPlayer.CurrentSong;
|
||||
if (currentSong == null)
|
||||
return;
|
||||
var currentValue = musicPlayer.ToggleRepeatSong();
|
||||
await channel.SendMessageAsync(currentValue ?
|
||||
$"🎵🔂`Repeating track:`{currentSong.PrettyName}" :
|
||||
$"🎵🔂`Current track repeat stopped.`")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task RepeatPl(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
var currentValue = musicPlayer.ToggleRepeatPlaylist();
|
||||
await channel.SendMessageAsync($"🎵🔁`Repeat playlist {(currentValue ? "enabled" : "disabled")}`").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
///
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Save(IMessage imsg, [Remainder] string name)
|
||||
//{
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
//}
|
||||
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Load(IMessage imsg, [Remainder] string name)
|
||||
//{
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
//}
|
||||
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Playlists(IMessage imsg, [Remainder] string num)
|
||||
//{
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
//}
|
||||
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task DeletePlaylist(IMessage imsg, [Remainder] string pl)
|
||||
//{
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
//}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Goto(IMessage imsg, int time)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
if (((IGuildUser)imsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
|
||||
if (time < 0)
|
||||
return;
|
||||
|
||||
var currentSong = musicPlayer.CurrentSong;
|
||||
|
||||
if (currentSong == null)
|
||||
return;
|
||||
|
||||
//currentSong.PrintStatusMessage = false;
|
||||
var gotoSong = currentSong.Clone();
|
||||
gotoSong.SkipTo = time;
|
||||
musicPlayer.AddSong(gotoSong, 0);
|
||||
musicPlayer.Next();
|
||||
|
||||
var minutes = (time / 60).ToString();
|
||||
var seconds = (time % 60).ToString();
|
||||
|
||||
if (minutes.Length == 1)
|
||||
minutes = "0" + minutes;
|
||||
if (seconds.Length == 1)
|
||||
seconds = "0" + seconds;
|
||||
|
||||
await channel.SendMessageAsync($"`Skipped to {minutes}:{seconds}`").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task GetLink(IMessage imsg, int index = 0)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
|
||||
var selSong = musicPlayer.Playlist.DefaultIfEmpty(null).ElementAtOrDefault(index - 1);
|
||||
if (selSong == null)
|
||||
{
|
||||
await channel.SendMessageAsync("Could not select song, likely wrong index");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
await channel.SendMessageAsync($"🎶`Selected song {selSong.SongInfo.Title}:` <{selSong.SongInfo.Query}>").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var curSong = musicPlayer.CurrentSong;
|
||||
if (curSong == null)
|
||||
return;
|
||||
await channel.SendMessageAsync($"🎶`Current song:` <{curSong.SongInfo.Query}>").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Autoplay(IMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||
return;
|
||||
|
||||
if (!musicPlayer.ToggleAutoplay())
|
||||
await channel.SendMessageAsync("🎶`Autoplay disabled.`").ConfigureAwait(false);
|
||||
else
|
||||
await channel.SendMessageAsync("🎶`Autoplay enabled.`").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static async Task QueueSong(IGuildUser queuer, ITextChannel textCh, IVoiceChannel voiceCh, string query, bool silent = false, MusicType musicType = MusicType.Normal)
|
||||
{
|
||||
if (voiceCh == null || voiceCh.Guild != textCh.Guild)
|
||||
{
|
||||
if (!silent)
|
||||
await textCh.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false);
|
||||
throw new ArgumentNullException(nameof(voiceCh));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
|
||||
throw new ArgumentException("💢 Invalid query for queue song.", nameof(query));
|
||||
|
||||
var musicPlayer = MusicPlayers.GetOrAdd(textCh.Guild.Id, server =>
|
||||
{
|
||||
//todo DB
|
||||
float vol = 100;// SpecificConfigurations.Default.Of(server.Id).DefaultMusicVolume;
|
||||
var mp = new MusicPlayer(voiceCh, vol);
|
||||
|
||||
|
||||
IMessage playingMessage = null;
|
||||
IMessage lastFinishedMessage = null;
|
||||
mp.OnCompleted += async (s, song) =>
|
||||
{
|
||||
if (song.PrintStatusMessage)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (lastFinishedMessage != null)
|
||||
await lastFinishedMessage.DeleteAsync().ConfigureAwait(false);
|
||||
if (playingMessage != null)
|
||||
await playingMessage.DeleteAsync().ConfigureAwait(false);
|
||||
lastFinishedMessage = await textCh.SendMessageAsync($"🎵`Finished`{song.PrettyName}").ConfigureAwait(false);
|
||||
if (mp.Autoplay && mp.Playlist.Count == 0 && song.SongInfo.Provider == "YouTube")
|
||||
{
|
||||
await QueueSong(queuer.Guild.GetCurrentUser(), textCh, voiceCh, (await NadekoBot.Google.GetRelatedVideosAsync(song.SongInfo.Query, 4)).ToList().Shuffle().FirstOrDefault(), silent, musicType).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
mp.OnStarted += async (s, song) =>
|
||||
{
|
||||
if (song.PrintStatusMessage)
|
||||
{
|
||||
var sender = s as MusicPlayer;
|
||||
if (sender == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(sender.Volume * 100)}%`";
|
||||
playingMessage = await textCh.SendMessageAsync(msgTxt).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
};
|
||||
return mp;
|
||||
});
|
||||
Song resolvedSong;
|
||||
try
|
||||
{
|
||||
musicPlayer.ThrowIfQueueFull();
|
||||
resolvedSong = await Song.ResolveSong(query, musicType).ConfigureAwait(false);
|
||||
|
||||
musicPlayer.AddSong(resolvedSong, queuer.Username);
|
||||
}
|
||||
catch (PlaylistFullException)
|
||||
{
|
||||
await textCh.SendMessageAsync($"🎵 `Queue is full at {musicPlayer.MaxQueueSize}/{musicPlayer.MaxQueueSize}.` ");
|
||||
throw;
|
||||
}
|
||||
if (!silent)
|
||||
{
|
||||
var queuedMessage = await textCh.SendMessageAsync($"🎵`Queued`{resolvedSong.PrettyName} **at** `#{musicPlayer.Playlist.Count + 1}`").ConfigureAwait(false);
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await queuedMessage.DeleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}).ConfigureAwait(false);
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
using System.Net;
|
||||
using Discord.WebSocket;
|
||||
using NadekoBot.Extensions;
|
||||
|
||||
namespace NadekoBot.Modules.NSFW
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Hentai(IMessage imsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Danbooru(IMessage imsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetDanbooruImageLink(tag).ConfigureAwait(false);
|
||||
@@ -58,7 +59,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Gelbooru(IMessage imsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetRule34ImageLink(tag).ConfigureAwait(false);
|
||||
@@ -72,7 +73,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Rule34(IMessage imsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetGelbooruImageLink(tag).ConfigureAwait(false);
|
||||
@@ -86,7 +87,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task E621(IMessage imsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetE621ImageLink(tag).ConfigureAwait(false);
|
||||
@@ -100,7 +101,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Cp(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false);
|
||||
}
|
||||
@@ -109,7 +110,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Boobs(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
try
|
||||
{
|
||||
JToken obj;
|
||||
@@ -129,7 +130,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Butts(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -173,9 +174,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
{
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
http.DefaultRequestHeaders.Clear();
|
||||
http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1");
|
||||
http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
||||
http.AddFakeHeaders();
|
||||
|
||||
var webpage = await http.GetStringAsync("http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags="+ tag.Replace(" ", "_")).ConfigureAwait(false);
|
||||
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
||||
@@ -211,9 +210,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
{
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
http.DefaultRequestHeaders.Clear();
|
||||
http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1");
|
||||
http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
||||
http.AddFakeHeaders();
|
||||
var data = await http.GetStreamAsync("http://e621.net/post/index.xml?tags=" + Uri.EscapeUriString(tags) + "%20order:random&limit=1");
|
||||
var doc = XDocument.Load(data);
|
||||
return doc.Descendants("file_url").FirstOrDefault().Value;
|
||||
|
@@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Poke(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Anime(IMessage imsg, [Remainder] string query = null)
|
||||
// {
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||
// string result;
|
||||
@@ -36,7 +36,7 @@
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Manga(IMessage imsg, [Remainder] string query = null)
|
||||
// {
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||
// string result;
|
||||
|
@@ -72,11 +72,11 @@
|
||||
// {
|
||||
// await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||
|
||||
// string from = e.GetArg("from-to").ToLowerInvariant().Split('>')[0];
|
||||
// string to = e.GetArg("from-to").ToLowerInvariant().Split('>')[1];
|
||||
// string from = from-to.ToLowerInvariant().Split('>')[0];
|
||||
// string to = from-to.ToLowerInvariant().Split('>')[1];
|
||||
|
||||
// float quantity = 1.0f;
|
||||
// if (!float.TryParse(e.GetArg("quantity"), out quantity))
|
||||
// if (!float.TryParse(quantity, out quantity))
|
||||
// {
|
||||
// quantity = 1.0f;
|
||||
// }
|
||||
|
@@ -27,7 +27,7 @@
|
||||
// private CustomParser parser = new CustomParser();
|
||||
// private Func<CommandEventArgs, Task> EvalFunc() => async e =>
|
||||
// {
|
||||
// string expression = e.GetArg("expression")?.Trim();
|
||||
// string expression = expression?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(expression))
|
||||
// {
|
||||
// return;
|
||||
|
@@ -46,7 +46,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Yomama(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var response = await http.GetStringAsync("http://api.yomomma.info/").ConfigureAwait(false);
|
||||
@@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Randjoke(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var response = await http.GetStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
|
||||
@@ -70,7 +70,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ChuckNorris(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var response = await http.GetStringAsync("http://api.icndb.com/jokes/random/").ConfigureAwait(false);
|
||||
@@ -82,7 +82,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task WowJoke(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!wowJokes.Any())
|
||||
{
|
||||
@@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task MagicItem(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var rng = new Random();
|
||||
var item = magicItems[rng.Next(0, magicItems.Count)].ToString();
|
||||
|
||||
|
@@ -35,7 +35,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Lolban(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
|
||||
|
||||
@@ -124,9 +124,9 @@ namespace NadekoBot.Modules.Searches
|
||||
// try
|
||||
// {
|
||||
// //get role
|
||||
// var role = ResolvePos(e.GetArg("position"));
|
||||
// var role = ResolvePos(position);
|
||||
// var resolvedRole = role;
|
||||
// var name = e.GetArg("champ").Replace(" ", "").ToLower();
|
||||
// var name = champ.Replace(" ", "").ToLower();
|
||||
// CachedChampion champ = null;
|
||||
|
||||
// if (CachedChampionImages.TryGetValue(name + "_" + resolvedRole, out champ))
|
||||
@@ -136,7 +136,7 @@ namespace NadekoBot.Modules.Searches
|
||||
// await e.Channel.SendFile("champ.png", champ.ImageStream).ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// var allData = JArray.Parse(await Classes.http.GetStringAsync($"http://api.champion.gg/champion/{name}?api_key={NadekoBot.Creds.LOLAPIKey}").ConfigureAwait(false));
|
||||
// var allData = JArray.Parse(await Classes.http.GetStringAsync($"http://api.champion.gg/champion/{name}?api_key={NadekoBot.Credentials.LOLAPIKey}").ConfigureAwait(false));
|
||||
// JToken data = null;
|
||||
// if (role != null)
|
||||
// {
|
||||
@@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Searches
|
||||
// roles[i] = ">" + roles[i] + "<";
|
||||
// }
|
||||
// var general = JArray.Parse(await http.GetStringAsync($"http://api.champion.gg/stats/" +
|
||||
// $"champs/{name}?api_key={NadekoBot.Creds.LOLAPIKey}")
|
||||
// $"champs/{name}?api_key={NadekoBot.Credentials.LOLAPIKey}")
|
||||
// .ConfigureAwait(false))
|
||||
// .FirstOrDefault(jt => jt["role"].ToString() == role)?["general"];
|
||||
// if (general == null)
|
||||
|
@@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Memelist(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<Dictionary<string, string>>(await http.GetStringAsync("http://memegen.link/templates/"))
|
||||
@@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Memegen(IMessage imsg, string meme, string topText, string botText)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var top = Uri.EscapeDataString(topText.Replace(' ', '-'));
|
||||
var bot = Uri.EscapeDataString(botText.Replace(' ', '-'));
|
||||
|
@@ -26,7 +26,7 @@ $@"`Title:` {WebUtility.HtmlDecode(Title)} {(string.IsNullOrEmpty(OriginalTitle)
|
||||
`Genre:` {GenresAsString}
|
||||
`Link:` <{ImdbURL}>
|
||||
`Plot:` {System.Net.WebUtility.HtmlDecode(Plot.TrimTo(500))}
|
||||
`img:` " + Poster.ShortenUrl().Result;
|
||||
`img:` " + Poster;
|
||||
public string GenresAsString =>
|
||||
string.Join(", ", Genres);
|
||||
}
|
||||
|
@@ -1,269 +1,277 @@
|
||||
//using Discord.Commands;
|
||||
//using NadekoBot.Classes;
|
||||
//using Newtonsoft.Json.Linq;
|
||||
//using System;
|
||||
//using System.IO;
|
||||
//using System.Net;
|
||||
//using System.Text.RegularExpressions;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//todo DI into partials
|
||||
//namespace NadekoBot.Modules.Searches
|
||||
//{
|
||||
// internal class OsuCommands : DiscordCommand
|
||||
// {
|
||||
// public OsuCommands(DiscordModule module) : base(module)
|
||||
// {
|
||||
// }
|
||||
namespace NadekoBot.Modules.Searches
|
||||
{
|
||||
public partial class Searches
|
||||
{
|
||||
[Group]
|
||||
public class OsuCommands
|
||||
{
|
||||
private Logger _log;
|
||||
|
||||
// internal override void Init(CommandGroupBuilder cgb)
|
||||
// {
|
||||
// cgb.CreateCommand(Module.Prefix + "osu")
|
||||
// .Description($"Shows osu stats for a player. | `{Prefix}osu Name` or `{Prefix}osu Name taiko`")
|
||||
// .Parameter("usr", ParameterType.Required)
|
||||
// .Parameter("mode", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(e.GetArg("usr")))
|
||||
// return;
|
||||
public OsuCommands()
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Osu(IMessage imsg, string usr, string mode)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// using (WebClient cl = new WebClient())
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var m = 0;
|
||||
// if (!string.IsNullOrWhiteSpace(e.GetArg("mode")))
|
||||
// {
|
||||
// m = ResolveGameMode(e.GetArg("mode"));
|
||||
// }
|
||||
if (string.IsNullOrWhiteSpace(usr))
|
||||
return;
|
||||
|
||||
// cl.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
|
||||
// cl.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.2; Win64; x64)");
|
||||
// cl.DownloadDataAsync(new Uri($"http://lemmmy.pw/osusig/sig.php?uname={ e.GetArg("usr") }&flagshadow&xpbar&xpbarhex&pp=2&mode={m}"));
|
||||
// cl.DownloadDataCompleted += async (s, cle) =>
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)).ConfigureAwait(false);
|
||||
// await channel.SendMessageAsync($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`").ConfigureAwait(false);
|
||||
// }
|
||||
// catch { }
|
||||
// };
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// await channel.SendMessageAsync("💢 Failed retrieving osu signature :\\").ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
using (HttpClient http = new HttpClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
var m = 0;
|
||||
if (!string.IsNullOrWhiteSpace(mode))
|
||||
{
|
||||
m = ResolveGameMode(mode);
|
||||
}
|
||||
http.AddFakeHeaders();
|
||||
var res = await http.GetStreamAsync(new Uri($"http://lemmmy.pw/osusig/sig.php?uname={ usr }&flagshadow&xpbar&xpbarhex&pp=2&mode={m}")).ConfigureAwait(false);
|
||||
|
||||
// cgb.CreateCommand(Module.Prefix + "osu b")
|
||||
// .Description($"Shows information about an osu beatmap. |`{Prefix}osu b` https://osu.ppy.sh/s/127712`")
|
||||
// .Parameter("map", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(NadekoBot.Creds.OsuAPIKey))
|
||||
// {
|
||||
// await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
res.Position = 0;
|
||||
await channel.SendFileAsync(res, $"{usr}.png").ConfigureAwait(false);
|
||||
await channel.SendMessageAsync($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(usr)}\n`Image provided by https://lemmmy.pw/osusig`").ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await channel.SendMessageAsync("💢 Failed retrieving osu signature :\\").ConfigureAwait(false);
|
||||
_log.Warn(ex, "Osu command failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(e.GetArg("map")))
|
||||
// return;
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Osub(IMessage imsg, [Remainder] string map)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// try
|
||||
// {
|
||||
// var mapId = ResolveMap(e.GetArg("map"));
|
||||
// var reqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Creds.OsuAPIKey}&{mapId}";
|
||||
// var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false))[0];
|
||||
// var sb = new System.Text.StringBuilder();
|
||||
// var starRating = Math.Round(Double.Parse($"{obj["difficultyrating"]}", CultureInfo.InvariantCulture), 2);
|
||||
// var time = TimeSpan.FromSeconds(Double.Parse($"{obj["total_length"]}")).ToString(@"mm\:ss");
|
||||
// sb.AppendLine($"{obj["artist"]} - {obj["title"]}, mapped by {obj["creator"]}. https://osu.ppy.sh/s/{obj["beatmapset_id"]}");
|
||||
// sb.AppendLine($"{starRating} stars, {obj["bpm"]} BPM | AR{obj["diff_approach"]}, CS{obj["diff_size"]}, OD{obj["diff_overall"]} | Length: {time}");
|
||||
// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// await channel.SendMessageAsync("Something went wrong.");
|
||||
// }
|
||||
// });
|
||||
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.OsuApiKey))
|
||||
{
|
||||
await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// cgb.CreateCommand(Module.Prefix + "osu top5")
|
||||
// .Description($"Displays a user's top 5 plays. |`{Prefix}osu top5 Name`")
|
||||
// .Parameter("usr", ParameterType.Required)
|
||||
// .Parameter("mode", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(NadekoBot.Creds.OsuAPIKey))
|
||||
// {
|
||||
// await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
if (string.IsNullOrWhiteSpace(map))
|
||||
return;
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(e.GetArg("usr")))
|
||||
// {
|
||||
// await channel.SendMessageAsync("💢 Please provide a username.").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
try
|
||||
{
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var mapId = ResolveMap(map);
|
||||
var reqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Credentials.OsuApiKey}&{mapId}";
|
||||
var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false))[0];
|
||||
var sb = new System.Text.StringBuilder();
|
||||
var starRating = Math.Round(Double.Parse($"{obj["difficultyrating"]}", CultureInfo.InvariantCulture), 2);
|
||||
var time = TimeSpan.FromSeconds(Double.Parse($"{obj["total_length"]}")).ToString(@"mm\:ss");
|
||||
sb.AppendLine($"{obj["artist"]} - {obj["title"]}, mapped by {obj["creator"]}. https://osu.ppy.sh/s/{obj["beatmapset_id"]}");
|
||||
sb.AppendLine($"{starRating} stars, {obj["bpm"]} BPM | AR{obj["diff_approach"]}, CS{obj["diff_size"]}, OD{obj["diff_overall"]} | Length: {time}");
|
||||
await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await channel.SendMessageAsync("Something went wrong.");
|
||||
_log.Warn(ex, "Osub command failed");
|
||||
}
|
||||
}
|
||||
|
||||
// try
|
||||
// {
|
||||
// var m = 0;
|
||||
// if (!string.IsNullOrWhiteSpace(e.GetArg("mode")))
|
||||
// {
|
||||
// m = ResolveGameMode(e.GetArg("mode"));
|
||||
// }
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Osu5(IMessage imsg, string user, [Remainder] string mode)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.OsuApiKey))
|
||||
{
|
||||
await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// var reqString = $"https://osu.ppy.sh/api/get_user_best?k={NadekoBot.Creds.OsuAPIKey}&u={Uri.EscapeDataString(e.GetArg("usr"))}&type=string&limit=5&m={m}";
|
||||
// var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false));
|
||||
// var sb = new System.Text.StringBuilder($"`Top 5 plays for {e.GetArg("usr")}:`\n```xl" + Environment.NewLine);
|
||||
// foreach (var item in obj)
|
||||
// {
|
||||
// var mapReqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Creds.OsuAPIKey}&b={item["beatmap_id"]}";
|
||||
// var map = JArray.Parse(await http.GetStringAsync(mapReqString).ConfigureAwait(false))[0];
|
||||
// var pp = Math.Round(Double.Parse($"{item["pp"]}", CultureInfo.InvariantCulture), 2);
|
||||
// var acc = CalculateAcc(item, m);
|
||||
// var mods = ResolveMods(Int32.Parse($"{item["enabled_mods"]}"));
|
||||
// if (mods != "+")
|
||||
// sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | **{mods,-10}** | /b/{item["beatmap_id"]}");
|
||||
// else
|
||||
// sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | /b/{item["beatmap_id"]}");
|
||||
// }
|
||||
// sb.Append("```");
|
||||
// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// await channel.SendMessageAsync("Something went wrong.");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
if (string.IsNullOrWhiteSpace(user))
|
||||
{
|
||||
await channel.SendMessageAsync("💢 Please provide a username.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
var m = 0;
|
||||
if (!string.IsNullOrWhiteSpace(mode))
|
||||
{
|
||||
m = ResolveGameMode(mode);
|
||||
}
|
||||
|
||||
// //https://osu.ppy.sh/wiki/Accuracy
|
||||
// private static Double CalculateAcc(JToken play, int mode)
|
||||
// {
|
||||
// if (mode == 0)
|
||||
// {
|
||||
// var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["count300"]}") * 300;
|
||||
// var totalHits = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countmiss"]}");
|
||||
// totalHits *= 300;
|
||||
// return Math.Round(hitPoints / totalHits * 100, 2);
|
||||
// }
|
||||
// else if (mode == 1)
|
||||
// {
|
||||
// var hitPoints = Double.Parse($"{play["countmiss"]}") * 0 + Double.Parse($"{play["count100"]}") * 0.5 + Double.Parse($"{play["count300"]}") * 1;
|
||||
// var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
||||
// hitPoints *= 300;
|
||||
// totalHits *= 300;
|
||||
// return Math.Round(hitPoints / totalHits * 100, 2);
|
||||
// }
|
||||
// else if (mode == 2)
|
||||
// {
|
||||
// var fruitsCaught = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
||||
// var totalFruits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countkatu"]}");
|
||||
// return Math.Round(fruitsCaught / totalFruits * 100, 2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["countkatu"]}") * 200 + (Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}")) * 300;
|
||||
// var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["countkatu"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}");
|
||||
// totalHits *= 300;
|
||||
// return Math.Round(hitPoints / totalHits * 100, 2);
|
||||
// }
|
||||
// }
|
||||
var reqString = $"https://osu.ppy.sh/api/get_user_best?k={NadekoBot.Credentials.OsuApiKey}&u={Uri.EscapeDataString(user)}&type=string&limit=5&m={m}";
|
||||
var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false));
|
||||
var sb = new System.Text.StringBuilder($"`Top 5 plays for {user}:`\n```xl" + Environment.NewLine);
|
||||
foreach (var item in obj)
|
||||
{
|
||||
var mapReqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Credentials.OsuApiKey}&b={item["beatmap_id"]}";
|
||||
var map = JArray.Parse(await http.GetStringAsync(mapReqString).ConfigureAwait(false))[0];
|
||||
var pp = Math.Round(Double.Parse($"{item["pp"]}", CultureInfo.InvariantCulture), 2);
|
||||
var acc = CalculateAcc(item, m);
|
||||
var mods = ResolveMods(Int32.Parse($"{item["enabled_mods"]}"));
|
||||
if (mods != "+")
|
||||
sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | **{mods,-10}** | /b/{item["beatmap_id"]}");
|
||||
else
|
||||
sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | /b/{item["beatmap_id"]}");
|
||||
}
|
||||
sb.Append("```");
|
||||
await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await channel.SendMessageAsync("Something went wrong.");
|
||||
_log.Warn(ex, "Osu5 command failed");
|
||||
}
|
||||
|
||||
// private static string ResolveMap(string mapLink)
|
||||
// {
|
||||
// Match s = new Regex(@"osu.ppy.sh\/s\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
// Match b = new Regex(@"osu.ppy.sh\/b\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
// Match p = new Regex(@"osu.ppy.sh\/p\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
// Match m = new Regex(@"&m=", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
// if (s.Success)
|
||||
// {
|
||||
// var mapId = mapLink.Substring(mapLink.IndexOf("/s/") + 3);
|
||||
// return $"s={mapId}";
|
||||
// }
|
||||
// else if (b.Success)
|
||||
// {
|
||||
// if (m.Success)
|
||||
// return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("/b/") + 3))}";
|
||||
// else
|
||||
// return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3)}";
|
||||
// }
|
||||
// else if (p.Success)
|
||||
// {
|
||||
// if (m.Success)
|
||||
// return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("?b=") + 3))}";
|
||||
// else
|
||||
// return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3)}";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return $"s={mapLink}"; //just a default incase an ID number was provided by itself (non-url)?
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// private static int ResolveGameMode(string mode)
|
||||
// {
|
||||
// switch (mode.ToLower())
|
||||
// {
|
||||
// case "std":
|
||||
// case "standard":
|
||||
// return 0;
|
||||
// case "taiko":
|
||||
// return 1;
|
||||
// case "ctb":
|
||||
// case "catchthebeat":
|
||||
// return 2;
|
||||
// case "mania":
|
||||
// case "osu!mania":
|
||||
// return 3;
|
||||
// default:
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
//https://osu.ppy.sh/wiki/Accuracy
|
||||
private static Double CalculateAcc(JToken play, int mode)
|
||||
{
|
||||
if (mode == 0)
|
||||
{
|
||||
var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["count300"]}") * 300;
|
||||
var totalHits = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countmiss"]}");
|
||||
totalHits *= 300;
|
||||
return Math.Round(hitPoints / totalHits * 100, 2);
|
||||
}
|
||||
else if (mode == 1)
|
||||
{
|
||||
var hitPoints = Double.Parse($"{play["countmiss"]}") * 0 + Double.Parse($"{play["count100"]}") * 0.5 + Double.Parse($"{play["count300"]}") * 1;
|
||||
var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
||||
hitPoints *= 300;
|
||||
totalHits *= 300;
|
||||
return Math.Round(hitPoints / totalHits * 100, 2);
|
||||
}
|
||||
else if (mode == 2)
|
||||
{
|
||||
var fruitsCaught = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
||||
var totalFruits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countkatu"]}");
|
||||
return Math.Round(fruitsCaught / totalFruits * 100, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["countkatu"]}") * 200 + (Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}")) * 300;
|
||||
var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["countkatu"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}");
|
||||
totalHits *= 300;
|
||||
return Math.Round(hitPoints / totalHits * 100, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// //https://github.com/ppy/osu-api/wiki#mods
|
||||
// private static string ResolveMods(int mods)
|
||||
// {
|
||||
// var modString = $"+";
|
||||
private static string ResolveMap(string mapLink)
|
||||
{
|
||||
Match s = new Regex(@"osu.ppy.sh\/s\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
Match b = new Regex(@"osu.ppy.sh\/b\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
Match p = new Regex(@"osu.ppy.sh\/p\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
Match m = new Regex(@"&m=", RegexOptions.IgnoreCase).Match(mapLink);
|
||||
if (s.Success)
|
||||
{
|
||||
var mapId = mapLink.Substring(mapLink.IndexOf("/s/") + 3);
|
||||
return $"s={mapId}";
|
||||
}
|
||||
else if (b.Success)
|
||||
{
|
||||
if (m.Success)
|
||||
return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("/b/") + 3))}";
|
||||
else
|
||||
return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3)}";
|
||||
}
|
||||
else if (p.Success)
|
||||
{
|
||||
if (m.Success)
|
||||
return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("?b=") + 3))}";
|
||||
else
|
||||
return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"s={mapLink}"; //just a default incase an ID number was provided by itself (non-url)?
|
||||
}
|
||||
}
|
||||
|
||||
// if (IsBitSet(mods, 0))
|
||||
// modString += "NF";
|
||||
// if (IsBitSet(mods, 1))
|
||||
// modString += "EZ";
|
||||
// if (IsBitSet(mods, 8))
|
||||
// modString += "HT";
|
||||
private static int ResolveGameMode(string mode)
|
||||
{
|
||||
switch (mode.ToLower())
|
||||
{
|
||||
case "std":
|
||||
case "standard":
|
||||
return 0;
|
||||
case "taiko":
|
||||
return 1;
|
||||
case "ctb":
|
||||
case "catchthebeat":
|
||||
return 2;
|
||||
case "mania":
|
||||
case "osu!mania":
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// if (IsBitSet(mods, 3))
|
||||
// modString += "HD";
|
||||
// if (IsBitSet(mods, 4))
|
||||
// modString += "HR";
|
||||
// if (IsBitSet(mods, 6) && !IsBitSet(mods, 9))
|
||||
// modString += "DT";
|
||||
// if (IsBitSet(mods, 9))
|
||||
// modString += "NC";
|
||||
// if (IsBitSet(mods, 10))
|
||||
// modString += "FL";
|
||||
//https://github.com/ppy/osu-api/wiki#mods
|
||||
private static string ResolveMods(int mods)
|
||||
{
|
||||
var modString = $"+";
|
||||
|
||||
// if (IsBitSet(mods, 5))
|
||||
// modString += "SD";
|
||||
// if (IsBitSet(mods, 14))
|
||||
// modString += "PF";
|
||||
if (IsBitSet(mods, 0))
|
||||
modString += "NF";
|
||||
if (IsBitSet(mods, 1))
|
||||
modString += "EZ";
|
||||
if (IsBitSet(mods, 8))
|
||||
modString += "HT";
|
||||
|
||||
// if (IsBitSet(mods, 7))
|
||||
// modString += "RX";
|
||||
// if (IsBitSet(mods, 11))
|
||||
// modString += "AT";
|
||||
// if (IsBitSet(mods, 12))
|
||||
// modString += "SO";
|
||||
// return modString;
|
||||
// }
|
||||
if (IsBitSet(mods, 3))
|
||||
modString += "HD";
|
||||
if (IsBitSet(mods, 4))
|
||||
modString += "HR";
|
||||
if (IsBitSet(mods, 6) && !IsBitSet(mods, 9))
|
||||
modString += "DT";
|
||||
if (IsBitSet(mods, 9))
|
||||
modString += "NC";
|
||||
if (IsBitSet(mods, 10))
|
||||
modString += "FL";
|
||||
|
||||
// private static bool IsBitSet(int mods, int pos)
|
||||
// {
|
||||
// return (mods & (1 << pos)) != 0;
|
||||
// }
|
||||
if (IsBitSet(mods, 5))
|
||||
modString += "SD";
|
||||
if (IsBitSet(mods, 14))
|
||||
modString += "PF";
|
||||
|
||||
// }
|
||||
//}
|
||||
if (IsBitSet(mods, 7))
|
||||
modString += "RX";
|
||||
if (IsBitSet(mods, 11))
|
||||
modString += "AT";
|
||||
if (IsBitSet(mods, 12))
|
||||
modString += "SO";
|
||||
return modString;
|
||||
}
|
||||
|
||||
private static bool IsBitSet(int mods, int pos) =>
|
||||
(mods & (1 << pos)) != 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Pokemon(IMessage imsg, [Remainder] string pokemon = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
pokemon = pokemon?.Trim().ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(pokemon))
|
||||
@@ -64,7 +64,7 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task PokemonAbility(IMessage imsg, [Remainder] string ability = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
ability = ability?.Trim().ToUpperInvariant().Replace(" ", "");
|
||||
if (string.IsNullOrWhiteSpace(ability))
|
||||
|
@@ -154,7 +154,7 @@
|
||||
// .AddCheck(SimpleCheckers.ManageServer())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var stream = e.GetArg("username")?.Trim();
|
||||
// var stream = username?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(stream))
|
||||
// return;
|
||||
// try
|
||||
@@ -183,7 +183,7 @@
|
||||
// .Parameter("username", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var stream = e.GetArg("username")?.Trim();
|
||||
// var stream = username?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(stream))
|
||||
// return;
|
||||
// try
|
||||
@@ -212,7 +212,7 @@
|
||||
// .Parameter("username", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var stream = e.GetArg("username")?.Trim();
|
||||
// var stream = username?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(stream))
|
||||
// return;
|
||||
// try
|
||||
@@ -241,7 +241,7 @@
|
||||
// .Parameter("username", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var username = e.GetArg("username")?.ToLower().Trim();
|
||||
// var username = username?.ToLower().Trim();
|
||||
// if (string.IsNullOrWhiteSpace(username))
|
||||
// return;
|
||||
|
||||
@@ -298,7 +298,7 @@
|
||||
// private Func<CommandEventArgs, Task> TrackStream(StreamNotificationConfig.StreamType type) =>
|
||||
// async e =>
|
||||
// {
|
||||
// var username = e.GetArg("username")?.ToLowerInvariant();
|
||||
// var username = username?.ToLowerInvariant();
|
||||
// if (string.IsNullOrWhiteSpace(username))
|
||||
// return;
|
||||
|
||||
|
@@ -8,7 +8,6 @@ using System.Net.Http;
|
||||
using NadekoBot.Services;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net;
|
||||
using Discord.WebSocket;
|
||||
@@ -20,17 +19,17 @@ namespace NadekoBot.Modules.Searches
|
||||
[Module("~", AppendSpace = false)]
|
||||
public partial class Searches : DiscordModule
|
||||
{
|
||||
private IYoutubeService _yt { get; }
|
||||
private IGoogleApiService _google { get; }
|
||||
|
||||
public Searches(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client, IYoutubeService youtube) : base(loc, cmds, config, client)
|
||||
public Searches(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client, IGoogleApiService youtube) : base(loc, cmds, config, client)
|
||||
{
|
||||
_yt = youtube;
|
||||
_google = youtube;
|
||||
}
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Weather(IMessage imsg, string city, string country)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
city = city.Replace(" ", "");
|
||||
country = city.Replace(" ", "");
|
||||
string response;
|
||||
@@ -51,9 +50,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Youtube(IMessage imsg, [Remainder] string query = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||
var result = (await _yt.FindVideosByKeywordsAsync(query, 1)).FirstOrDefault();
|
||||
var result = (await _google.GetVideosByKeywordsAsync(query, 1)).FirstOrDefault();
|
||||
if (string.IsNullOrWhiteSpace(result))
|
||||
{
|
||||
await channel.SendMessageAsync("No results found for that query.");
|
||||
@@ -66,7 +65,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Imdb(IMessage imsg, [Remainder] string query = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (!(await ValidateQuery(imsg.Channel as ITextChannel, query).ConfigureAwait(false))) return;
|
||||
await imsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
@@ -90,7 +89,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task RandomCat(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
await channel.SendMessageAsync(JObject.Parse(
|
||||
@@ -103,7 +102,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task RandomDog(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
await channel.SendMessageAsync("http://random.dog/" + await http.GetStringAsync("http://random.dog/woof").ConfigureAwait(false)).ConfigureAwait(false);
|
||||
@@ -114,7 +113,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task I(IMessage imsg, [Remainder] string query = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
return;
|
||||
@@ -144,7 +143,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Ir(IMessage imsg, [Remainder] string query = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
return;
|
||||
@@ -176,13 +175,13 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Lmgtfy(IMessage imsg, [Remainder] string ffs = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ffs))
|
||||
return;
|
||||
|
||||
await channel.SendMessageAsync(await $"<http://lmgtfy.com/?q={ Uri.EscapeUriString(ffs) }>".ShortenUrl())
|
||||
await channel.SendMessageAsync(await _google.ShortenUrl($"<http://lmgtfy.com/?q={ Uri.EscapeUriString(ffs) }>"))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -190,7 +189,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Google(IMessage imsg, [Remainder] string terms = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
|
||||
terms = terms?.Trim();
|
||||
@@ -204,8 +203,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Hearthstone(IMessage imsg, [Remainder] string name = null)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var arg = e.GetArg("name");
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
// var arg = name;
|
||||
// if (string.IsNullOrWhiteSpace(arg))
|
||||
// {
|
||||
// await channel.SendMessageAsync("💢 Please enter a card name to search for.").ConfigureAwait(false);
|
||||
@@ -249,7 +248,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Ud(IMessage imsg, [Remainder] string query = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var arg = query;
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
@@ -269,7 +268,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
var sb = new System.Text.StringBuilder();
|
||||
sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}");
|
||||
sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}");
|
||||
sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl().ConfigureAwait(false)}>");
|
||||
sb.Append($"`Link:` <{await _google.ShortenUrl(items["list"][0]["permalink"].ToString()).ConfigureAwait(false)}>");
|
||||
await channel.SendMessageAsync(sb.ToString());
|
||||
}
|
||||
catch
|
||||
@@ -283,7 +282,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Hashtag(IMessage imsg, [Remainder] string query = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var arg = query;
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
@@ -305,7 +304,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
var items = JObject.Parse(res);
|
||||
var str = $@"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString()}
|
||||
`Definition:` {items["defs"]["def"]["text"].ToString()}
|
||||
`Link:` <{await items["defs"]["def"]["uri"].ToString().ShortenUrl().ConfigureAwait(false)}>";
|
||||
`Link:` <{await _google.ShortenUrl(items["defs"]["def"]["uri"].ToString()).ConfigureAwait(false)}>";
|
||||
await channel.SendMessageAsync(str);
|
||||
}
|
||||
catch
|
||||
@@ -318,7 +317,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Quote(IMessage imsg)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// var quote = NadekoBot.Config.Quotes[rng.Next(0, NadekoBot.Config.Quotes.Count)].ToString();
|
||||
// await channel.SendMessageAsync(quote).ConfigureAwait(false);
|
||||
@@ -328,7 +327,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Catfact(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var response = await http.GetStringAsync("http://catfacts-api.appspot.com/api/facts").ConfigureAwait(false);
|
||||
@@ -342,7 +341,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Revav(IMessage imsg, [Remainder] string arg = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var usrStr = arg?.Trim().ToUpperInvariant();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(usrStr))
|
||||
@@ -359,7 +358,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Revimg(IMessage imsg, [Remainder] string imageLink = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
imageLink = imageLink?.Trim() ?? "";
|
||||
|
||||
if (string.IsNullOrWhiteSpace(imageLink))
|
||||
@@ -371,7 +370,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Safebooru(IMessage imsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetSafebooruImageLink(tag).ConfigureAwait(false);
|
||||
@@ -385,7 +384,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Wiki(IMessage imsg, [Remainder] string query = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
query = query?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
@@ -406,7 +405,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Clr(IMessage imsg, [Remainder] string color = null)
|
||||
//{
|
||||
// var channel = imsg.Channel as ITextChannel;
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// color = color?.Trim().Replace("#", "");
|
||||
// if (string.IsNullOrWhiteSpace((string)color))
|
||||
@@ -431,7 +430,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Videocall(IMessage imsg, [Remainder] string arg = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -454,7 +453,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Avatar(IMessage imsg, [Remainder] string mention = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
var usr = imsg.MentionedUsers.FirstOrDefault();
|
||||
if (usr == null)
|
||||
@@ -462,7 +461,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
await channel.SendMessageAsync("Invalid user specified.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await channel.SendMessageAsync(await usr.AvatarUrl.ShortenUrl()).ConfigureAwait(false);
|
||||
await channel.SendMessageAsync(await _google.ShortenUrl(usr.AvatarUrl).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static async Task<string> GetSafebooruImageLink(string tag)
|
||||
|
@@ -20,7 +20,7 @@ namespace NadekoBot.Modules.Translator
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Translate(IMessage imsg, string langs, [Remainder] string text = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Translator
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Translangs(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendTableAsync(GoogleTranslator.Instance.Languages, str => str, columns: 4);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
// TrelloConfiguration.Deserializer = serializer;
|
||||
// TrelloConfiguration.JsonFactory = new ManateeFactory();
|
||||
// TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
|
||||
// TrelloAuthorization.Default.AppKey = NadekoBot.Creds.TrelloAppKey;
|
||||
// TrelloAuthorization.Default.AppKey = NadekoBot.Credentials.TrelloAppKey;
|
||||
// //TrelloAuthorization.Default.UserToken = "[your user token]";
|
||||
|
||||
// Discord.Channel bound = null;
|
||||
@@ -80,7 +80,7 @@
|
||||
// try
|
||||
// {
|
||||
// bound = e.Channel;
|
||||
// board = new Board(e.GetArg("board_id").Trim());
|
||||
// board = new Board(board_id.Trim());
|
||||
// board.Refresh();
|
||||
// await channel.SendMessageAsync("Successfully bound to this channel and board " + board.Name);
|
||||
// t.Start();
|
||||
@@ -121,15 +121,15 @@
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (!NadekoBot.IsOwner(imsg.Author.Id)) return;
|
||||
// if (bound == null || board == null || bound != e.Channel || e.GetArg("list_name") == null) return;
|
||||
// if (bound == null || board == null || bound != e.Channel || list_name == null) return;
|
||||
|
||||
// int num;
|
||||
// var success = int.TryParse(e.GetArg("list_name"), out num);
|
||||
// var success = int.TryParse(list_name, out num);
|
||||
// List list = null;
|
||||
// if (success && num <= board.Lists.Count() && num > 0)
|
||||
// list = board.Lists[num - 1];
|
||||
// else
|
||||
// list = board.Lists.FirstOrDefault(l => l.Name == e.GetArg("list_name"));
|
||||
// list = board.Lists.FirstOrDefault(l => l.Name == list_name);
|
||||
|
||||
|
||||
// if (list != null)
|
||||
|
@@ -94,7 +94,7 @@
|
||||
// .Parameter("message", ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var meorchStr = e.GetArg("meorchannel").ToUpperInvariant();
|
||||
// var meorchStr = meorchannel.ToUpperInvariant();
|
||||
// Channel ch;
|
||||
// bool isPrivate = false;
|
||||
// if (meorchStr == "ME")
|
||||
@@ -117,7 +117,7 @@
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var timeStr = e.GetArg("time");
|
||||
// var timeStr = time;
|
||||
|
||||
// var m = regex.Match(timeStr);
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
// ChannelId = (long)ch.Id,
|
||||
// IsPrivate = isPrivate,
|
||||
// When = time,
|
||||
// Message = e.GetArg("message"),
|
||||
// Message = message,
|
||||
// UserId = (long)imsg.Author.Id,
|
||||
// ServerId = (long)e.Server.Id
|
||||
// };
|
||||
@@ -175,7 +175,7 @@
|
||||
|
||||
// reminders.Add(StartNewReminder(rem));
|
||||
|
||||
// await channel.SendMessageAsync($"⏰ I will remind \"{ch.Name}\" to \"{e.GetArg("message").ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false);
|
||||
// await channel.SendMessageAsync($"⏰ I will remind \"{ch.Name}\" to \"{message.ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false);
|
||||
// });
|
||||
// cgb.CreateCommand(Module.Prefix + "remindmsg")
|
||||
// .Description("Sets message for when the remind is triggered. " +
|
||||
@@ -185,7 +185,7 @@
|
||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// var arg = e.GetArg("msg")?.Trim();
|
||||
// var arg = msg?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(arg))
|
||||
// return;
|
||||
|
||||
|
@@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Utility
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task WhoPlays(IMessage imsg, [Remainder] string game = null)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
game = game.Trim().ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(game))
|
||||
return;
|
||||
@@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(roles))
|
||||
return;
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
var arg = roles.Split(',').Select(r => r.Trim().ToUpperInvariant());
|
||||
string send = _l["`Here is a list of users in a specfic role:`"];
|
||||
foreach (var roleStr in arg.Where(str => !string.IsNullOrWhiteSpace(str) && str != "@EVERYONE" && str != "EVERYONE"))
|
||||
@@ -121,11 +121,11 @@ namespace NadekoBot.Modules.Utility
|
||||
var guild = (msg.Channel as ITextChannel).Guild;
|
||||
if (target != null)
|
||||
{
|
||||
await msg.Reply($"`List of roles for **{target.Username}**:` \n• " + string.Join("\n• ", target.Roles.Except(new[] { guild.EveryoneRole })));
|
||||
await msg.Reply($"`List of roles for **{target.Username}**:` \n• " + string.Join("\n• ", target.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => r.Position)));
|
||||
}
|
||||
else
|
||||
{
|
||||
await msg.Reply("`List of roles:` \n• " + string.Join("\n• ", (msg.Channel as ITextChannel).Guild.Roles.Except(new[] { guild.EveryoneRole })));
|
||||
await msg.Reply("`List of roles:` \n• " + string.Join("\n• ", (msg.Channel as ITextChannel).Guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r=>r.Position)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace NadekoBot.Modules.Utility
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Stats(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync(await NadekoBot.Stats.Print());
|
||||
}
|
||||
|
Reference in New Issue
Block a user