ConfigureAwait ALL THE THINGS
This commit is contained in:
parent
f8d52e2307
commit
113c2b43bd
@ -1,24 +1,27 @@
|
|||||||
using System;
|
using Discord;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord;
|
|
||||||
using System.IO;
|
|
||||||
using System.Drawing;
|
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Extensions {
|
namespace NadekoBot.Extensions
|
||||||
|
{
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
private static Random rng = new Random();
|
private static Random rng = new Random();
|
||||||
|
|
||||||
public static string Scramble(this string word) {
|
public static string Scramble(this string word)
|
||||||
|
{
|
||||||
|
|
||||||
var letters = word.ToArray();
|
var letters = word.ToArray();
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for (var i = 0; i < letters.Length; i++) {
|
for (var i = 0; i < letters.Length; i++)
|
||||||
|
{
|
||||||
if (letters[i] == ' ')
|
if (letters[i] == ' ')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -32,9 +35,10 @@ namespace NadekoBot.Extensions {
|
|||||||
if (letters[i] != ' ')
|
if (letters[i] != ' ')
|
||||||
letters[i] = '_';
|
letters[i] = '_';
|
||||||
}
|
}
|
||||||
return "`"+string.Join(" ", letters)+"`";
|
return "`" + string.Join(" ", letters) + "`";
|
||||||
}
|
}
|
||||||
public static string TrimTo(this string str, int num, bool hideDots = false) {
|
public static string TrimTo(this string str, int num, bool hideDots = false)
|
||||||
|
{
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
throw new ArgumentOutOfRangeException(nameof(num), "TrimTo argument cannot be less than 0");
|
throw new ArgumentOutOfRangeException(nameof(num), "TrimTo argument cannot be less than 0");
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
@ -52,7 +56,8 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <param name="num"></param>
|
/// <param name="num"></param>
|
||||||
/// <param name="es"></param>
|
/// <param name="es"></param>
|
||||||
/// <returns>String with the correct singular/plural form</returns>
|
/// <returns>String with the correct singular/plural form</returns>
|
||||||
public static string SnPl(this string str, int? num,bool es = false) {
|
public static string SnPl(this string str, int? num, bool es = false)
|
||||||
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
throw new ArgumentNullException(nameof(str));
|
throw new ArgumentNullException(nameof(str));
|
||||||
if (num == null)
|
if (num == null)
|
||||||
@ -67,7 +72,7 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <param name="message">Message to be sent</param>
|
/// <param name="message">Message to be sent</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<Message> Send(this CommandEventArgs e, string message)
|
public static async Task<Message> Send(this CommandEventArgs e, string message)
|
||||||
=> await e.Channel.SendMessage(message);
|
=> await e.Channel.SendMessage(message).ConfigureAwait(false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a message to the channel from which MessageEventArg came.
|
/// Sends a message to the channel from which MessageEventArg came.
|
||||||
@ -79,7 +84,7 @@ namespace NadekoBot.Extensions {
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(message))
|
if (string.IsNullOrWhiteSpace(message))
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage(message);
|
await e.Channel.SendMessage(message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -90,7 +95,7 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task Send(this Channel c, string message)
|
public static async Task Send(this Channel c, string message)
|
||||||
{
|
{
|
||||||
await c.SendMessage(message);
|
await c.SendMessage(message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -101,7 +106,7 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task Send(this User u, string message)
|
public static async Task Send(this User u, string message)
|
||||||
{
|
{
|
||||||
await u.SendMessage(message);
|
await u.SendMessage(message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -112,7 +117,7 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task Reply(this CommandEventArgs e, string message)
|
public static async Task Reply(this CommandEventArgs e, string message)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " " + message);
|
await e.Channel.SendMessage(e.User.Mention + " " + message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -123,7 +128,7 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task Reply(this MessageEventArgs e, string message)
|
public static async Task Reply(this MessageEventArgs e, string message)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " " + message);
|
await e.Channel.SendMessage(e.User.Mention + " " + message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -154,7 +159,7 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <param name="action"></param>
|
/// <param name="action"></param>
|
||||||
public static async Task<string> ShortenUrl(this string str) => await SearchHelper.ShortenUrl(str);
|
public static async Task<string> ShortenUrl(this string str) => await SearchHelper.ShortenUrl(str).ConfigureAwait(false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the program runtime
|
/// Gets the program runtime
|
||||||
@ -167,40 +172,49 @@ namespace NadekoBot.Extensions {
|
|||||||
public static string Matrix(this string s)
|
public static string Matrix(this string s)
|
||||||
=>
|
=>
|
||||||
string.Join("", s.Select(c => c.ToString() + " ̵̢̬̜͉̞̭̖̰͋̉̎ͬ̔̇̌̀".TrimTo(rng.Next(0, 12), true)));
|
string.Join("", s.Select(c => c.ToString() + " ̵̢̬̜͉̞̭̖̰͋̉̎ͬ̔̇̌̀".TrimTo(rng.Next(0, 12), true)));
|
||||||
//.Replace("`", "");
|
//.Replace("`", "");
|
||||||
|
|
||||||
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) {
|
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
|
||||||
foreach (var element in source) {
|
{
|
||||||
|
foreach (var element in source)
|
||||||
|
{
|
||||||
action(element);
|
action(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//http://www.dotnetperls.com/levenshtein
|
//http://www.dotnetperls.com/levenshtein
|
||||||
public static int LevenshteinDistance(this string s, string t) {
|
public static int LevenshteinDistance(this string s, string t)
|
||||||
|
{
|
||||||
var n = s.Length;
|
var n = s.Length;
|
||||||
var m = t.Length;
|
var m = t.Length;
|
||||||
var d = new int[n + 1, m + 1];
|
var d = new int[n + 1, m + 1];
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
if (n == 0) {
|
if (n == 0)
|
||||||
|
{
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m == 0) {
|
if (m == 0)
|
||||||
|
{
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
for (var i = 0; i <= n; d[i, 0] = i++) {
|
for (var i = 0; i <= n; d[i, 0] = i++)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var j = 0; j <= m; d[0, j] = j++) {
|
for (var j = 0; j <= m; d[0, j] = j++)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
for (var i = 1; i <= n; i++) {
|
for (var i = 1; i <= n; i++)
|
||||||
|
{
|
||||||
//Step 4
|
//Step 4
|
||||||
for (var j = 1; j <= m; j++) {
|
for (var j = 1; j <= m; j++)
|
||||||
|
{
|
||||||
// Step 5
|
// Step 5
|
||||||
var cost = (t[j - 1] == s[i - 1]) ? 0 : 1;
|
var cost = (t[j - 1] == s[i - 1]) ? 0 : 1;
|
||||||
|
|
||||||
@ -223,7 +237,8 @@ namespace NadekoBot.Extensions {
|
|||||||
public static int GiB(this int value) => value.MiB() * 1024;
|
public static int GiB(this int value) => value.MiB() * 1024;
|
||||||
public static int GB(this int value) => value.MB() * 1000;
|
public static int GB(this int value) => value.MB() * 1000;
|
||||||
|
|
||||||
public static Stream ToStream(this Image img, System.Drawing.Imaging.ImageFormat format = null) {
|
public static Stream ToStream(this Image img, System.Drawing.Imaging.ImageFormat format = null)
|
||||||
|
{
|
||||||
if (format == null)
|
if (format == null)
|
||||||
format = System.Drawing.Imaging.ImageFormat.Jpeg;
|
format = System.Drawing.Imaging.ImageFormat.Jpeg;
|
||||||
var stream = new MemoryStream();
|
var stream = new MemoryStream();
|
||||||
@ -237,22 +252,26 @@ namespace NadekoBot.Extensions {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="images">The Images you want to merge.</param>
|
/// <param name="images">The Images you want to merge.</param>
|
||||||
/// <returns>Merged bitmap</returns>
|
/// <returns>Merged bitmap</returns>
|
||||||
public static Bitmap Merge(this IEnumerable<Image> images,int reverseScaleFactor = 1) {
|
public static Bitmap Merge(this IEnumerable<Image> images, int reverseScaleFactor = 1)
|
||||||
|
{
|
||||||
var imageArray = images as Image[] ?? images.ToArray();
|
var imageArray = images as Image[] ?? images.ToArray();
|
||||||
if (!imageArray.Any()) return null;
|
if (!imageArray.Any()) return null;
|
||||||
var width = imageArray.Sum(i => i.Width);
|
var width = imageArray.Sum(i => i.Width);
|
||||||
var height = imageArray.First().Height ;
|
var height = imageArray.First().Height;
|
||||||
var bitmap = new Bitmap(width / reverseScaleFactor, height / reverseScaleFactor);
|
var bitmap = new Bitmap(width / reverseScaleFactor, height / reverseScaleFactor);
|
||||||
var r = new Random();
|
var r = new Random();
|
||||||
var offsetx = 0;
|
var offsetx = 0;
|
||||||
foreach (var img in imageArray) {
|
foreach (var img in imageArray)
|
||||||
|
{
|
||||||
var bm = new Bitmap(img);
|
var bm = new Bitmap(img);
|
||||||
for (var w = 0; w < img.Width; w++) {
|
for (var w = 0; w < img.Width; w++)
|
||||||
for (var h = 0; h < bitmap.Height; h++) {
|
{
|
||||||
bitmap.SetPixel(w / reverseScaleFactor + offsetx, h , bm.GetPixel(w, h *reverseScaleFactor));
|
for (var h = 0; h < bitmap.Height; h++)
|
||||||
|
{
|
||||||
|
bitmap.SetPixel(w / reverseScaleFactor + offsetx, h, bm.GetPixel(w, h * reverseScaleFactor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offsetx += img.Width/reverseScaleFactor;
|
offsetx += img.Width / reverseScaleFactor;
|
||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
@ -264,6 +283,6 @@ namespace NadekoBot.Extensions {
|
|||||||
/// <param name="reverseScaleFactor"></param>
|
/// <param name="reverseScaleFactor"></param>
|
||||||
/// <returns>Merged bitmap</returns>
|
/// <returns>Merged bitmap</returns>
|
||||||
public static async Task<Bitmap> MergeAsync(this IEnumerable<Image> images, int reverseScaleFactor = 1) =>
|
public static async Task<Bitmap> MergeAsync(this IEnumerable<Image> images, int reverseScaleFactor = 1) =>
|
||||||
await Task.Run(() => images.Merge(reverseScaleFactor));
|
await Task.Run(() => images.Merge(reverseScaleFactor)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace NadekoBot.Classes
|
|||||||
UserId = (long)u.Id,
|
UserId = (long)u.Id,
|
||||||
Value = amount,
|
Value = amount,
|
||||||
});
|
});
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
if (silent)
|
if (silent)
|
||||||
return;
|
return;
|
||||||
@ -26,7 +26,7 @@ namespace NadekoBot.Classes
|
|||||||
{
|
{
|
||||||
flows += NadekoBot.Config.CurrencySign;
|
flows += NadekoBot.Config.CurrencySign;
|
||||||
}
|
}
|
||||||
await u.SendMessage("👑Congratulations!👑\nYou received: " + flows);
|
await u.SendMessage("👑Congratulations!👑\nYou received: " + flows).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool RemoveFlowers(Discord.User u, string reason, int amount)
|
public static bool RemoveFlowers(Discord.User u, string reason, int amount)
|
||||||
|
@ -29,7 +29,7 @@ namespace NadekoBot
|
|||||||
public int VoiceChannelsCount { get; private set; } = 0;
|
public int VoiceChannelsCount { get; private set; } = 0;
|
||||||
|
|
||||||
private readonly Timer commandLogTimer = new Timer() { Interval = 10000 };
|
private readonly Timer commandLogTimer = new Timer() { Interval = 10000 };
|
||||||
//private readonly Timer carbonStatusTimer = new Timer() { Interval = 3600000 };
|
private readonly Timer carbonStatusTimer = new Timer() { Interval = 3600000 };
|
||||||
|
|
||||||
static NadekoStats() { }
|
static NadekoStats() { }
|
||||||
|
|
||||||
@ -50,25 +50,25 @@ namespace NadekoBot
|
|||||||
TextChannelsCount = channelsArray.Count(c => c.Type == ChannelType.Text);
|
TextChannelsCount = channelsArray.Count(c => c.Type == ChannelType.Text);
|
||||||
VoiceChannelsCount = channelsArray.Count() - TextChannelsCount;
|
VoiceChannelsCount = channelsArray.Count() - TextChannelsCount;
|
||||||
|
|
||||||
NadekoBot.Client.JoinedServer += async (s, e) =>
|
NadekoBot.Client.JoinedServer += (s, e) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerCount++;
|
ServerCount++;
|
||||||
TextChannelsCount += e.Server.TextChannels.Count();
|
TextChannelsCount += e.Server.TextChannels.Count();
|
||||||
VoiceChannelsCount += e.Server.VoiceChannels.Count();
|
VoiceChannelsCount += e.Server.VoiceChannels.Count();
|
||||||
await SendUpdateToCarbon().ConfigureAwait(false);
|
//await SendUpdateToCarbon().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
NadekoBot.Client.LeftServer += async (s, e) =>
|
NadekoBot.Client.LeftServer += (s, e) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerCount--;
|
ServerCount--;
|
||||||
TextChannelsCount -= e.Server.TextChannels.Count();
|
TextChannelsCount -= e.Server.TextChannels.Count();
|
||||||
VoiceChannelsCount -= e.Server.VoiceChannels.Count();
|
VoiceChannelsCount -= e.Server.VoiceChannels.Count();
|
||||||
await SendUpdateToCarbon().ConfigureAwait(false);
|
//await SendUpdateToCarbon().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
@ -98,27 +98,26 @@ namespace NadekoBot
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
|
carbonStatusTimer.Elapsed += async (s, e) => await SendUpdateToCarbon().ConfigureAwait(false);
|
||||||
|
carbonStatusTimer.Start();
|
||||||
}
|
}
|
||||||
|
HttpClient carbonClient = new HttpClient();
|
||||||
private async Task SendUpdateToCarbon()
|
private async Task SendUpdateToCarbon()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.CarbonKey))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.CarbonKey))
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var client = new HttpClient())
|
using (var content = new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||||
{
|
|
||||||
using (var content = new FormUrlEncodedContent(new Dictionary<string, string> {
|
|
||||||
{ "servercount", NadekoBot.Client.Servers.Count().ToString() },
|
{ "servercount", NadekoBot.Client.Servers.Count().ToString() },
|
||||||
{ "key", NadekoBot.Creds.CarbonKey }
|
{ "key", NadekoBot.Creds.CarbonKey }
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
content.Headers.Clear();
|
content.Headers.Clear();
|
||||||
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
var res = await client.PostAsync("https://www.carbonitex.net/discord/data/botdata.php", content);
|
var res = await carbonClient.PostAsync("https://www.carbonitex.net/discord/data/botdata.php", content).ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -165,7 +164,7 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
if (statsStopwatch.Elapsed.Seconds < 4 &&
|
if (statsStopwatch.Elapsed.Seconds < 4 &&
|
||||||
!string.IsNullOrWhiteSpace(statsCache)) return statsCache;
|
!string.IsNullOrWhiteSpace(statsCache)) return statsCache;
|
||||||
await LoadStats();
|
await LoadStats().ConfigureAwait(false);
|
||||||
statsStopwatch.Restart();
|
statsStopwatch.Restart();
|
||||||
return statsCache;
|
return statsCache;
|
||||||
}
|
}
|
||||||
@ -174,12 +173,13 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
await Task.Delay(new TimeSpan(0, 30, 0));
|
await Task.Delay(new TimeSpan(0, 30, 0)).ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var onlineUsers = await Task.Run(() => NadekoBot.Client.Servers.Sum(x => x.Users.Count()));
|
var onlineUsers = await Task.Run(() => NadekoBot.Client.Servers.Sum(x => x.Users.Count())).ConfigureAwait(false);
|
||||||
var realOnlineUsers = await Task.Run(() => NadekoBot.Client.Servers
|
var realOnlineUsers = await Task.Run(() => NadekoBot.Client.Servers
|
||||||
.Sum(x => x.Users.Count(u => u.Status == UserStatus.Online)));
|
.Sum(x => x.Users.Count(u => u.Status == UserStatus.Online)))
|
||||||
|
.ConfigureAwait(false);
|
||||||
var connectedServers = NadekoBot.Client.Servers.Count();
|
var connectedServers = NadekoBot.Client.Servers.Count();
|
||||||
|
|
||||||
Classes.DbHandler.Instance.InsertData(new DataModels.Stats
|
Classes.DbHandler.Instance.InsertData(new DataModels.Stats
|
||||||
@ -223,7 +223,7 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Error in ran command DB write.");
|
Console.WriteLine("Error in ran command DB write.");
|
||||||
}
|
}
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,15 +41,15 @@ namespace NadekoBot.Classes
|
|||||||
httpClient.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value);
|
httpClient.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return await httpClient.GetStreamAsync(url);
|
return await httpClient.GetStreamAsync(url).ConfigureAwait(false);
|
||||||
case RequestHttpMethod.Post:
|
case RequestHttpMethod.Post:
|
||||||
FormUrlEncodedContent formContent = null;
|
FormUrlEncodedContent formContent = null;
|
||||||
if (headers != null)
|
if (headers != null)
|
||||||
{
|
{
|
||||||
formContent = new FormUrlEncodedContent(headers);
|
formContent = new FormUrlEncodedContent(headers);
|
||||||
}
|
}
|
||||||
var message = await httpClient.PostAsync(url, formContent);
|
var message = await httpClient.PostAsync(url, formContent).ConfigureAwait(false);
|
||||||
return await message.Content.ReadAsStreamAsync();
|
return await message.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException("That type of request is unsupported.");
|
throw new NotImplementedException("That type of request is unsupported.");
|
||||||
}
|
}
|
||||||
@ -60,9 +60,9 @@ namespace NadekoBot.Classes
|
|||||||
RequestHttpMethod method = RequestHttpMethod.Get)
|
RequestHttpMethod method = RequestHttpMethod.Get)
|
||||||
{
|
{
|
||||||
|
|
||||||
using (var streamReader = new StreamReader(await GetResponseStreamAsync(url, headers, method)))
|
using (var streamReader = new StreamReader(await GetResponseStreamAsync(url, headers, method).ConfigureAwait(false)))
|
||||||
{
|
{
|
||||||
return await streamReader.ReadToEndAsync();
|
return await streamReader.ReadToEndAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ namespace NadekoBot.Classes
|
|||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
throw new ArgumentNullException(nameof(query));
|
throw new ArgumentNullException(nameof(query));
|
||||||
|
|
||||||
await RefreshAnilistToken();
|
await RefreshAnilistToken().ConfigureAwait(false);
|
||||||
|
|
||||||
var link = "http://anilist.co/api/anime/search/" + Uri.EscapeUriString(query);
|
var link = "http://anilist.co/api/anime/search/" + Uri.EscapeUriString(query);
|
||||||
var smallContent = "";
|
var smallContent = "";
|
||||||
@ -85,7 +85,7 @@ namespace NadekoBot.Classes
|
|||||||
rq.AddParameter("access_token", token);
|
rq.AddParameter("access_token", token);
|
||||||
var content = cl.Execute(rq).Content;
|
var content = cl.Execute(rq).Content;
|
||||||
|
|
||||||
return await Task.Run(() => JsonConvert.DeserializeObject<AnimeResult>(content));
|
return await Task.Run(() => JsonConvert.DeserializeObject<AnimeResult>(content)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<MangaResult> GetMangaData(string query)
|
public static async Task<MangaResult> GetMangaData(string query)
|
||||||
@ -93,7 +93,7 @@ namespace NadekoBot.Classes
|
|||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
throw new ArgumentNullException(nameof(query));
|
throw new ArgumentNullException(nameof(query));
|
||||||
|
|
||||||
await RefreshAnilistToken();
|
await RefreshAnilistToken().ConfigureAwait(false);
|
||||||
|
|
||||||
var link = "http://anilist.co/api/anime/search/" + Uri.EscapeUriString(query);
|
var link = "http://anilist.co/api/anime/search/" + Uri.EscapeUriString(query);
|
||||||
var smallContent = "";
|
var smallContent = "";
|
||||||
@ -107,7 +107,7 @@ namespace NadekoBot.Classes
|
|||||||
rq.AddParameter("access_token", token);
|
rq.AddParameter("access_token", token);
|
||||||
var content = cl.Execute(rq).Content;
|
var content = cl.Execute(rq).Content;
|
||||||
|
|
||||||
return await Task.Run(() => JsonConvert.DeserializeObject<MangaResult>(content));
|
return await Task.Run(() => JsonConvert.DeserializeObject<MangaResult>(content)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task RefreshAnilistToken()
|
private static async Task RefreshAnilistToken()
|
||||||
@ -123,8 +123,10 @@ namespace NadekoBot.Classes
|
|||||||
{"client_id", "kwoth-w0ki9"},
|
{"client_id", "kwoth-w0ki9"},
|
||||||
{"client_secret", "Qd6j4FIAi1ZK6Pc7N7V4Z"},
|
{"client_secret", "Qd6j4FIAi1ZK6Pc7N7V4Z"},
|
||||||
};
|
};
|
||||||
var content =
|
var content = await GetResponseStringAsync(
|
||||||
await GetResponseStringAsync("http://anilist.co/api/auth/access_token", headers, RequestHttpMethod.Post);
|
"http://anilist.co/api/auth/access_token",
|
||||||
|
headers,
|
||||||
|
RequestHttpMethod.Post).ConfigureAwait(false);
|
||||||
|
|
||||||
token = JObject.Parse(content)["access_token"].ToString();
|
token = JObject.Parse(content)["access_token"].ToString();
|
||||||
}
|
}
|
||||||
@ -132,7 +134,7 @@ namespace NadekoBot.Classes
|
|||||||
public static async Task<bool> ValidateQuery(Discord.Channel ch, string query)
|
public static async Task<bool> ValidateQuery(Discord.Channel ch, string query)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(query.Trim())) return true;
|
if (!string.IsNullOrEmpty(query.Trim())) return true;
|
||||||
await ch.Send("Please specify search parameters.");
|
await ch.Send("Please specify search parameters.").ConfigureAwait(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,12 +153,11 @@ namespace NadekoBot.Classes
|
|||||||
{
|
{
|
||||||
return $"http://www.youtube.com?v={match.Groups["id"].Value}";
|
return $"http://www.youtube.com?v={match.Groups["id"].Value}";
|
||||||
}
|
}
|
||||||
var response =
|
var response = await GetResponseStringAsync(
|
||||||
await
|
$"https://www.googleapis.com/youtube/v3/search?" +
|
||||||
GetResponseStringAsync($"https://www.googleapis.com/youtube/v3/search?" +
|
$"part=snippet&maxResults=1" +
|
||||||
$"part=snippet&maxResults=1" +
|
$"&q={Uri.EscapeDataString(keywords)}" +
|
||||||
$"&q={Uri.EscapeDataString(keywords)}" +
|
$"&key={NadekoBot.Creds.GoogleAPIKey}").ConfigureAwait(false);
|
||||||
$"&key={NadekoBot.Creds.GoogleAPIKey}");
|
|
||||||
dynamic obj = JObject.Parse(response);
|
dynamic obj = JObject.Parse(response);
|
||||||
return "http://www.youtube.com/watch?v=" + obj.items[0].id.videoId.ToString();
|
return "http://www.youtube.com/watch?v=" + obj.items[0].id.videoId.ToString();
|
||||||
}
|
}
|
||||||
@ -171,7 +172,7 @@ namespace NadekoBot.Classes
|
|||||||
$"&q={Uri.EscapeDataString(query)}" +
|
$"&q={Uri.EscapeDataString(query)}" +
|
||||||
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
||||||
|
|
||||||
var response = await GetResponseStringAsync(link);
|
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
||||||
dynamic obj = JObject.Parse(response);
|
dynamic obj = JObject.Parse(response);
|
||||||
|
|
||||||
return obj.items[0].id.playlistId.ToString();
|
return obj.items[0].id.playlistId.ToString();
|
||||||
@ -191,8 +192,8 @@ namespace NadekoBot.Classes
|
|||||||
$"&playlistId={playlist}" +
|
$"&playlistId={playlist}" +
|
||||||
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
||||||
|
|
||||||
var response = await GetResponseStringAsync(link);
|
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
||||||
var obj = await Task.Run(() => JObject.Parse(response));
|
var obj = await Task.Run(() => JObject.Parse(response)).ConfigureAwait(false);
|
||||||
|
|
||||||
return obj["items"].Select(item => "http://www.youtube.com/watch?v=" + item["contentDetails"]["videoId"]);
|
return obj["items"].Select(item => "http://www.youtube.com/watch?v=" + item["contentDetails"]["videoId"]);
|
||||||
}
|
}
|
||||||
@ -210,7 +211,7 @@ namespace NadekoBot.Classes
|
|||||||
if (!string.IsNullOrWhiteSpace(tag))
|
if (!string.IsNullOrWhiteSpace(tag))
|
||||||
link += $"&tags={tag.Replace(" ", "_")}";
|
link += $"&tags={tag.Replace(" ", "_")}";
|
||||||
|
|
||||||
var webpage = await GetResponseStringAsync(link);
|
var webpage = await GetResponseStringAsync(link).ConfigureAwait(false);
|
||||||
var matches = Regex.Matches(webpage, "data-large-file-url=\"(?<id>.*?)\"");
|
var matches = Regex.Matches(webpage, "data-large-file-url=\"(?<id>.*?)\"");
|
||||||
|
|
||||||
return $"http://danbooru.donmai.us" +
|
return $"http://danbooru.donmai.us" +
|
||||||
@ -221,7 +222,7 @@ namespace NadekoBot.Classes
|
|||||||
{
|
{
|
||||||
var url =
|
var url =
|
||||||
$"http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
$"http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
||||||
var webpage = await GetResponseStringAsync(url);
|
var webpage = await GetResponseStringAsync(url).ConfigureAwait(false);
|
||||||
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
@ -235,7 +236,7 @@ namespace NadekoBot.Classes
|
|||||||
var rng = new Random();
|
var rng = new Random();
|
||||||
var url =
|
var url =
|
||||||
$"http://safebooru.org/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
$"http://safebooru.org/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
||||||
var webpage = await GetResponseStringAsync(url);
|
var webpage = await GetResponseStringAsync(url).ConfigureAwait(false);
|
||||||
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
@ -248,7 +249,7 @@ namespace NadekoBot.Classes
|
|||||||
var rng = new Random();
|
var rng = new Random();
|
||||||
var url =
|
var url =
|
||||||
$"http://rule34.xxx/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
$"http://rule34.xxx/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}";
|
||||||
var webpage = await GetResponseStringAsync(url);
|
var webpage = await GetResponseStringAsync(url).ConfigureAwait(false);
|
||||||
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
@ -261,7 +262,7 @@ namespace NadekoBot.Classes
|
|||||||
{
|
{
|
||||||
var rng = new Random();
|
var rng = new Random();
|
||||||
var url = $"https://e621.net/post/index/{rng.Next(0, 5)}/{Uri.EscapeUriString(tags)}";
|
var url = $"https://e621.net/post/index/{rng.Next(0, 5)}/{Uri.EscapeUriString(tags)}";
|
||||||
var webpage = await GetResponseStringAsync(url); // first extract the post id and go to that posts page
|
var webpage = await GetResponseStringAsync(url).ConfigureAwait(false); // first extract the post id and go to that posts page
|
||||||
var matches = Regex.Matches(webpage, "\"file_url\":\"(?<url>.*?)\"");
|
var matches = Regex.Matches(webpage, "\"file_url\":\"(?<url>.*?)\"");
|
||||||
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
||||||
}
|
}
|
||||||
@ -277,19 +278,19 @@ namespace NadekoBot.Classes
|
|||||||
httpWebRequest.ContentType = "application/json";
|
httpWebRequest.ContentType = "application/json";
|
||||||
httpWebRequest.Method = "POST";
|
httpWebRequest.Method = "POST";
|
||||||
|
|
||||||
using (var streamWriter = new StreamWriter(await httpWebRequest.GetRequestStreamAsync()))
|
using (var streamWriter = new StreamWriter(await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)))
|
||||||
{
|
{
|
||||||
var json = "{\"longUrl\":\"" + url + "\"}";
|
var json = "{\"longUrl\":\"" + url + "\"}";
|
||||||
streamWriter.Write(json);
|
streamWriter.Write(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
var httpResponse = (await httpWebRequest.GetResponseAsync()) as HttpWebResponse;
|
var httpResponse = (await httpWebRequest.GetResponseAsync().ConfigureAwait(false)) as HttpWebResponse;
|
||||||
if (httpResponse == null) return "HTTP_RESPONSE_ERROR";
|
if (httpResponse == null) return "HTTP_RESPONSE_ERROR";
|
||||||
var responseStream = httpResponse.GetResponseStream();
|
var responseStream = httpResponse.GetResponseStream();
|
||||||
if (responseStream == null) return "RESPONSE_STREAM ERROR";
|
if (responseStream == null) return "RESPONSE_STREAM ERROR";
|
||||||
using (var streamReader = new StreamReader(responseStream))
|
using (var streamReader = new StreamReader(responseStream))
|
||||||
{
|
{
|
||||||
var responseText = await streamReader.ReadToEndAsync();
|
var responseText = await streamReader.ReadToEndAsync().ConfigureAwait(false);
|
||||||
return Regex.Match(responseText, @"""id"": ?""(?<id>.+)""").Groups["id"].Value;
|
return Regex.Match(responseText, @"""id"": ?""(?<id>.+)""").Groups["id"].Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,31 +57,31 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
if (!e.User.ServerPermissions.ManageRoles)
|
if (!e.User.ServerPermissions.ManageRoles)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You have insufficient permissions.");
|
await e.Channel.SendMessage("You have insufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var usr = e.Server.FindUsers(userName).FirstOrDefault();
|
var usr = e.Server.FindUsers(userName).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You failed to supply a valid username");
|
await e.Channel.SendMessage("You failed to supply a valid username").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You failed to supply a valid role");
|
await e.Channel.SendMessage("You failed to supply a valid role").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.AddRoles(role);
|
await usr.AddRoles(role).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"Successfully added role **{role.Name}** to user **{usr.Name}**");
|
await e.Channel.SendMessage($"Successfully added role **{role.Name}** to user **{usr.Name}**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Failed to add roles. Bot has insufficient permissions.\n");
|
await e.Channel.SendMessage("Failed to add roles. Bot has insufficient permissions.\n").ConfigureAwait(false);
|
||||||
Console.WriteLine(ex.ToString());
|
Console.WriteLine(ex.ToString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -101,25 +101,25 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var usr = e.Server.FindUsers(userName).FirstOrDefault();
|
var usr = e.Server.FindUsers(userName).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You failed to supply a valid username");
|
await e.Channel.SendMessage("You failed to supply a valid username").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You failed to supply a valid role");
|
await e.Channel.SendMessage("You failed to supply a valid role").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.RemoveRoles(role);
|
await usr.RemoveRoles(role).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"Successfully removed role **{role.Name}** from user **{usr.Name}**");
|
await e.Channel.SendMessage($"Successfully removed role **{role.Name}** from user **{usr.Name}**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Failed to remove roles. Most likely reason: Insufficient permissions.");
|
await e.Channel.SendMessage("Failed to remove roles. Most likely reason: Insufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -133,12 +133,12 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var r = await e.Server.CreateRole(e.GetArg("role_name"));
|
var r = await e.Server.CreateRole(e.GetArg("role_name")).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"Successfully created role **{r.Name}**.");
|
await e.Channel.SendMessage($"Successfully created role **{r.Name}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":warning: Unspecified error.");
|
await e.Channel.SendMessage(":warning: Unspecified error.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (!e.User.ServerPermissions.ManageRoles)
|
if (!e.User.ServerPermissions.ManageRoles)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You don't have permission to use this!");
|
await e.Channel.SendMessage("You don't have permission to use this!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
if (args.Count() != 2 && args.Count() != 4)
|
if (args.Count() != 2 && args.Count() != 4)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("The parameters are invalid.");
|
await e.Channel.SendMessage("The parameters are invalid.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("That role does not exist.");
|
await e.Channel.SendMessage("That role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -179,12 +179,12 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var green = Convert.ToByte(rgb ? int.Parse(e.Args[2]) : Convert.ToInt32(e.Args[1].Substring(2, 2), 16));
|
var green = Convert.ToByte(rgb ? int.Parse(e.Args[2]) : Convert.ToInt32(e.Args[1].Substring(2, 2), 16));
|
||||||
var blue = Convert.ToByte(rgb ? int.Parse(e.Args[3]) : Convert.ToInt32(e.Args[1].Substring(4, 2), 16));
|
var blue = Convert.ToByte(rgb ? int.Parse(e.Args[3]) : Convert.ToInt32(e.Args[1].Substring(4, 2), 16));
|
||||||
|
|
||||||
await role.Edit(color: new Color(red, green, blue));
|
await role.Edit(color: new Color(red, green, blue)).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.");
|
await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error occured, most likely invalid parameters or insufficient permissions.");
|
await e.Channel.SendMessage("Error occured, most likely invalid parameters or insufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -198,10 +198,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var usr = e.Server.FindUsers(e.GetArg("user")).FirstOrDefault();
|
var usr = e.Server.FindUsers(e.GetArg("user")).FirstOrDefault();
|
||||||
if (usr == null) return;
|
if (usr == null) return;
|
||||||
|
|
||||||
await e.Channel.SendMessage($"`List of roles for **{usr.Name}**:` \n• " + string.Join("\n• ", usr.Roles));
|
await e.Channel.SendMessage($"`List of roles for **{usr.Name}**:` \n• " + string.Join("\n• ", usr.Roles)).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("`List of roles:` \n• " + string.Join("\n• ", e.Server.Roles));
|
await e.Channel.SendMessage("`List of roles:` \n• " + string.Join("\n• ", e.Server.Roles)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "b").Alias(Prefix + "ban")
|
cgb.CreateCommand(Prefix + "b").Alias(Prefix + "ban")
|
||||||
@ -217,24 +217,24 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var usr = e.Server.FindUsers(user).FirstOrDefault();
|
var usr = e.Server.FindUsers(user).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("User not found.");
|
await e.Channel.SendMessage("User not found.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
if (!string.IsNullOrWhiteSpace(msg))
|
||||||
{
|
{
|
||||||
await usr.SendMessage($"**You have been BANNED from `{e.Server.Name}` server.**\n" +
|
await usr.SendMessage($"**You have been BANNED from `{e.Server.Name}` server.**\n" +
|
||||||
$"Reason: {msg}");
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Server.Ban(usr);
|
await e.Server.Ban(usr).ConfigureAwait(false);
|
||||||
|
|
||||||
await e.Channel.SendMessage("Banned user " + usr.Name + " Id: " + usr.Id);
|
await e.Channel.SendMessage("Banned user " + usr.Name + " Id: " + usr.Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error. Most likely I don't have sufficient permissions.");
|
await e.Channel.SendMessage("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -252,23 +252,23 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var usr = e.Server.FindUsers(user).FirstOrDefault();
|
var usr = e.Server.FindUsers(user).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("User not found.");
|
await e.Channel.SendMessage("User not found.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
if (!string.IsNullOrWhiteSpace(msg))
|
||||||
{
|
{
|
||||||
await usr.SendMessage($"**You have been KICKED from `{e.Server.Name}` server.**\n" +
|
await usr.SendMessage($"**You have been KICKED from `{e.Server.Name}` server.**\n" +
|
||||||
$"Reason: {msg}");
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.Kick();
|
await usr.Kick().ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage("Kicked user " + usr.Name + " Id: " + usr.Id);
|
await e.Channel.SendMessage("Kicked user " + usr.Name + " Id: " + usr.Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error. Most likely I don't have sufficient permissions.");
|
await e.Channel.SendMessage("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -279,7 +279,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (!e.User.ServerPermissions.MuteMembers)
|
if (!e.User.ServerPermissions.MuteMembers)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You do not have permission to do that.");
|
await e.Channel.SendMessage("You do not have permission to do that.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!e.Message.MentionedUsers.Any())
|
||||||
@ -288,13 +288,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in e.Message.MentionedUsers)
|
||||||
{
|
{
|
||||||
await u.Edit(isMuted: true);
|
await u.Edit(isMuted: true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Mute successful");
|
await e.Channel.SendMessage("Mute successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("I do not have permission to do that most likely.");
|
await e.Channel.SendMessage("I do not have permission to do that most likely.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (!e.User.ServerPermissions.MuteMembers)
|
if (!e.User.ServerPermissions.MuteMembers)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You do not have permission to do that.");
|
await e.Channel.SendMessage("You do not have permission to do that.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!e.Message.MentionedUsers.Any())
|
||||||
@ -314,13 +314,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in e.Message.MentionedUsers)
|
||||||
{
|
{
|
||||||
await u.Edit(isMuted: false);
|
await u.Edit(isMuted: false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Unmute successful");
|
await e.Channel.SendMessage("Unmute successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("I do not have permission to do that most likely.");
|
await e.Channel.SendMessage("I do not have permission to do that most likely.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (!e.User.ServerPermissions.DeafenMembers)
|
if (!e.User.ServerPermissions.DeafenMembers)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You do not have permission to do that.");
|
await e.Channel.SendMessage("You do not have permission to do that.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!e.Message.MentionedUsers.Any())
|
||||||
@ -341,13 +341,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in e.Message.MentionedUsers)
|
||||||
{
|
{
|
||||||
await u.Edit(isDeafened: true);
|
await u.Edit(isDeafened: true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Deafen successful");
|
await e.Channel.SendMessage("Deafen successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("I do not have permission to do that most likely.");
|
await e.Channel.SendMessage("I do not have permission to do that most likely.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (!e.User.ServerPermissions.DeafenMembers)
|
if (!e.User.ServerPermissions.DeafenMembers)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You do not have permission to do that.");
|
await e.Channel.SendMessage("You do not have permission to do that.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!e.Message.MentionedUsers.Any())
|
if (!e.Message.MentionedUsers.Any())
|
||||||
@ -368,13 +368,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
foreach (var u in e.Message.MentionedUsers)
|
foreach (var u in e.Message.MentionedUsers)
|
||||||
{
|
{
|
||||||
await u.Edit(isDeafened: false);
|
await u.Edit(isDeafened: false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Undeafen successful");
|
await e.Channel.SendMessage("Undeafen successful").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("I do not have permission to do that most likely.");
|
await e.Channel.SendMessage("I do not have permission to do that most likely.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -387,8 +387,11 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (e.User.ServerPermissions.ManageChannels)
|
if (e.User.ServerPermissions.ManageChannels)
|
||||||
{
|
{
|
||||||
await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault()?.Delete();
|
var ch = e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault();
|
||||||
await e.Channel.SendMessage($"Removed channel **{e.GetArg("channel_name")}**.");
|
if (ch == null)
|
||||||
|
return;
|
||||||
|
await ch.Delete().ConfigureAwait(false);
|
||||||
|
await e.Channel.SendMessage($"Removed channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@ -406,13 +409,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (e.User.ServerPermissions.ManageChannels)
|
if (e.User.ServerPermissions.ManageChannels)
|
||||||
{
|
{
|
||||||
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice);
|
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"Created voice channel **{e.GetArg("channel_name")}**.");
|
await e.Channel.SendMessage($"Created voice channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Insufficient permissions.");
|
await e.Channel.SendMessage("Insufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -427,13 +430,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var channel = e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Text).FirstOrDefault();
|
var channel = e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Text).FirstOrDefault();
|
||||||
if (channel == null) return;
|
if (channel == null) return;
|
||||||
await channel.Delete();
|
await channel.Delete().ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"Removed text channel **{e.GetArg("channel_name")}**.");
|
await e.Channel.SendMessage($"Removed text channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Insufficient permissions.");
|
await e.Channel.SendMessage("Insufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -446,13 +449,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (e.User.ServerPermissions.ManageChannels)
|
if (e.User.ServerPermissions.ManageChannels)
|
||||||
{
|
{
|
||||||
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text);
|
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"Added text channel **{e.GetArg("channel_name")}**.");
|
await e.Channel.SendMessage($"Added text channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Insufficient permissions.");
|
await e.Channel.SendMessage("Insufficient permissions.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -466,8 +469,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var topic = e.GetArg("topic");
|
var topic = e.GetArg("topic");
|
||||||
if (string.IsNullOrWhiteSpace(topic))
|
if (string.IsNullOrWhiteSpace(topic))
|
||||||
return;
|
return;
|
||||||
await e.Channel.Edit(topic: topic);
|
await e.Channel.Edit(topic: topic).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage(":ok: **New channel topic set.**");
|
await e.Channel.SendMessage(":ok: **New channel topic set.**").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "uid").Alias(Prefix + "userid")
|
cgb.CreateCommand(Prefix + "uid").Alias(Prefix + "userid")
|
||||||
@ -479,16 +482,16 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (!string.IsNullOrWhiteSpace(e.GetArg("user"))) usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
|
if (!string.IsNullOrWhiteSpace(e.GetArg("user"))) usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage($"Id of the user { usr.Name } is { usr.Id }");
|
await e.Channel.SendMessage($"Id of the user { usr.Name } is { usr.Id }").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "cid").Alias(Prefix + "channelid")
|
cgb.CreateCommand(Prefix + "cid").Alias(Prefix + "channelid")
|
||||||
.Description("Shows current channel ID.")
|
.Description("Shows current channel ID.")
|
||||||
.Do(async e => await e.Channel.SendMessage("This channel's ID is " + e.Channel.Id));
|
.Do(async e => await e.Channel.SendMessage("This channel's ID is " + e.Channel.Id).ConfigureAwait(false));
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "sid").Alias(Prefix + "serverid")
|
cgb.CreateCommand(Prefix + "sid").Alias(Prefix + "serverid")
|
||||||
.Description("Shows current server ID.")
|
.Description("Shows current server ID.")
|
||||||
.Do(async e => await e.Channel.SendMessage("This server's ID is " + e.Server.Id));
|
.Do(async e => await e.Channel.SendMessage("This server's ID is " + e.Server.Id).ConfigureAwait(false));
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "stats")
|
cgb.CreateCommand(Prefix + "stats")
|
||||||
.Description("Shows some basic stats for Nadeko.")
|
.Description("Shows some basic stats for Nadeko.")
|
||||||
@ -501,7 +504,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
.Description("Shows some basic stats for Nadeko.")
|
.Description("Shows some basic stats for Nadeko.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage((await NadekoStats.Instance.GetStats()).Matrix().TrimTo(1990));
|
await e.Channel.SendMessage((await NadekoStats.Instance.GetStats()).Matrix().TrimTo(1990)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "heap")
|
cgb.CreateCommand(Prefix + "heap")
|
||||||
@ -509,8 +512,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var heap = await Task.Run(() => NadekoStats.Instance.Heap());
|
var heap = await Task.Run(() => NadekoStats.Instance.Heap()).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"`Heap Size:` {heap}");
|
await e.Channel.SendMessage($"`Heap Size:` {heap}").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "prune")
|
cgb.CreateCommand(Prefix + "prune")
|
||||||
.Parameter("num", ParameterType.Required)
|
.Parameter("num", ParameterType.Required)
|
||||||
@ -522,10 +525,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (string.IsNullOrWhiteSpace(e.GetArg("num")) || !int.TryParse(e.GetArg("num"), out val) || val < 0)
|
if (string.IsNullOrWhiteSpace(e.GetArg("num")) || !int.TryParse(e.GetArg("num"), out val) || val < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var msg in await e.Channel.DownloadMessages(val))
|
foreach (var msg in await e.Channel.DownloadMessages(val).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
await msg.Delete();
|
await msg.Delete().ConfigureAwait(false);
|
||||||
await Task.Delay(100);
|
await Task.Delay(100).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -536,8 +539,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (NadekoBot.IsOwner(e.User.Id))
|
if (NadekoBot.IsOwner(e.User.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("`Shutting down.`");
|
await e.Channel.SendMessage("`Shutting down.`").ConfigureAwait(false);
|
||||||
await Task.Delay(2000);
|
await Task.Delay(2000).ConfigureAwait(false);
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -556,18 +559,18 @@ namespace NadekoBot.Modules.Administration
|
|||||||
}
|
}
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var msgs = (await e.Channel.DownloadMessages(100)).Where(m => m.User.Id == usrId);
|
var msgs = (await e.Channel.DownloadMessages(100).ConfigureAwait(false)).Where(m => m.User.Id == usrId);
|
||||||
foreach (var m in msgs)
|
foreach (var m in msgs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await m.Delete();
|
await m.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
await Task.Delay(200);
|
await Task.Delay(200).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "newname")
|
cgb.CreateCommand(Prefix + "newname")
|
||||||
@ -578,7 +581,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (!NadekoBot.IsOwner(e.User.Id) || e.GetArg("new_name") == null) return;
|
if (!NadekoBot.IsOwner(e.User.Id) || e.GetArg("new_name") == null) return;
|
||||||
|
|
||||||
await client.CurrentUser.Edit(NadekoBot.Creds.Password, e.GetArg("new_name"));
|
await client.CurrentUser.Edit(NadekoBot.Creds.Password, e.GetArg("new_name")).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "newavatar")
|
cgb.CreateCommand(Prefix + "newavatar")
|
||||||
@ -591,13 +594,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return;
|
return;
|
||||||
// Gather user provided URL.
|
// Gather user provided URL.
|
||||||
var avatarAddress = e.GetArg("img");
|
var avatarAddress = e.GetArg("img");
|
||||||
var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress);
|
var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
|
||||||
var image = System.Drawing.Image.FromStream(imageStream);
|
var image = System.Drawing.Image.FromStream(imageStream);
|
||||||
// Save the image to disk.
|
// Save the image to disk.
|
||||||
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
|
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
|
||||||
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: image.ToStream());
|
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: image.ToStream()).ConfigureAwait(false);
|
||||||
// Send confirm.
|
// Send confirm.
|
||||||
await e.Channel.SendMessage("New avatar set.");
|
await e.Channel.SendMessage("New avatar set.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "setgame")
|
cgb.CreateCommand(Prefix + "setgame")
|
||||||
@ -620,7 +623,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
output += p.Name + ": " + p.GetValue(e.User.ServerPermissions, null).ToString() + "\n";
|
output += p.Name + ": " + p.GetValue(e.User.ServerPermissions, null).ToString() + "\n";
|
||||||
}
|
}
|
||||||
output += "```";
|
output += "```";
|
||||||
await e.User.SendMessage(output);
|
await e.User.SendMessage(output).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
Server commsServer = null;
|
Server commsServer = null;
|
||||||
@ -637,10 +640,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (commsUser != null)
|
if (commsUser != null)
|
||||||
{
|
{
|
||||||
commsChannel = null;
|
commsChannel = null;
|
||||||
await e.Channel.SendMessage("User for comms set.");
|
await e.Channel.SendMessage("User for comms set.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("No server specified or user.");
|
await e.Channel.SendMessage("No server specified or user.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "commsserver")
|
cgb.CreateCommand(Prefix + "commsserver")
|
||||||
@ -651,9 +654,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||||
commsServer = client.FindServers(e.GetArg("server")).FirstOrDefault();
|
commsServer = client.FindServers(e.GetArg("server")).FirstOrDefault();
|
||||||
if (commsServer != null)
|
if (commsServer != null)
|
||||||
await e.Channel.SendMessage("Server for comms set.");
|
await e.Channel.SendMessage("Server for comms set.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("No such server.");
|
await e.Channel.SendMessage("No such server.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "commschannel")
|
cgb.CreateCommand(Prefix + "commschannel")
|
||||||
@ -666,10 +669,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (commsChannel != null)
|
if (commsChannel != null)
|
||||||
{
|
{
|
||||||
commsUser = null;
|
commsUser = null;
|
||||||
await e.Channel.SendMessage("Server for comms set.");
|
await e.Channel.SendMessage("Server for comms set.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("No server specified or channel is invalid.");
|
await e.Channel.SendMessage("No server specified or channel is invalid.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "send")
|
cgb.CreateCommand(Prefix + "send")
|
||||||
@ -679,11 +682,11 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||||
if (commsUser != null)
|
if (commsUser != null)
|
||||||
await commsUser.SendMessage(e.GetArg("msg"));
|
await commsUser.SendMessage(e.GetArg("msg")).ConfigureAwait(false);
|
||||||
else if (commsChannel != null)
|
else if (commsChannel != null)
|
||||||
await commsChannel.SendMessage(e.GetArg("msg"));
|
await commsChannel.SendMessage(e.GetArg("msg")).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("Failed. Make sure you've specified server and [channel or user]");
|
await e.Channel.SendMessage("Failed. Make sure you've specified server and [channel or user]").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "menrole")
|
cgb.CreateCommand(Prefix + "menrole")
|
||||||
@ -710,12 +713,12 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var curstr = send.Substring(0, 2000);
|
var curstr = send.Substring(0, 2000);
|
||||||
await
|
await
|
||||||
e.Channel.Send(curstr.Substring(0,
|
e.Channel.Send(curstr.Substring(0,
|
||||||
curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1));
|
curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1)).ConfigureAwait(false);
|
||||||
send = curstr.Substring(curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1) +
|
send = curstr.Substring(curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1) +
|
||||||
send.Substring(2000);
|
send.Substring(2000);
|
||||||
}
|
}
|
||||||
await e.Channel.Send(send);
|
await e.Channel.Send(send).ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "parsetosql")
|
cgb.CreateCommand(Prefix + "parsetosql")
|
||||||
@ -731,7 +734,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
SaveParseToDb<Request>("data/parsedata/Requests.json");
|
SaveParseToDb<Request>("data/parsedata/Requests.json");
|
||||||
SaveParseToDb<Stats>("data/parsedata/Stats.json");
|
SaveParseToDb<Stats>("data/parsedata/Stats.json");
|
||||||
SaveParseToDb<TypingArticle>("data/parsedata/TypingArticles.json");
|
SaveParseToDb<TypingArticle>("data/parsedata/TypingArticles.json");
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "unstuck")
|
cgb.CreateCommand(Prefix + "unstuck")
|
||||||
@ -752,8 +755,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var donatorsOrdered = rows.OrderByDescending(d => d.Amount);
|
var donatorsOrdered = rows.OrderByDescending(d => d.Amount);
|
||||||
string str = $"**Thanks to the people listed below for making this project happen!**\n";
|
string str = $"**Thanks to the people listed below for making this project happen!**\n";
|
||||||
|
|
||||||
await e.Channel.SendMessage(str + string.Join("⭐", donatorsOrdered.Select(d => d.UserName)));
|
await e.Channel.SendMessage(str + string.Join("⭐", donatorsOrdered.Select(d => d.UserName))).ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
//THIS IS INTENTED TO BE USED ONLY BY THE ORIGINAL BOT OWNER
|
//THIS IS INTENTED TO BE USED ONLY BY THE ORIGINAL BOT OWNER
|
||||||
@ -783,7 +786,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
e.Channel.SendMessage("Successfuly added a new donator. 👑");
|
e.Channel.SendMessage("Successfuly added a new donator. 👑");
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "videocall")
|
cgb.CreateCommand(Prefix + "videocall")
|
||||||
@ -799,7 +802,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
str += new Random().Next();
|
str += new Random().Next();
|
||||||
foreach (var usr in allUsrsArray)
|
foreach (var usr in allUsrsArray)
|
||||||
{
|
{
|
||||||
await usr.SendMessage(str);
|
await usr.SendMessage(str).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -25,7 +25,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
continue;
|
continue;
|
||||||
foreach (var chan in set.Except(new[] { e.Channel }))
|
foreach (var chan in set.Except(new[] { e.Channel }))
|
||||||
{
|
{
|
||||||
await chan.SendMessage(GetText(e.Server, e.Channel, e.User, e.Message));
|
await chan.SendMessage(GetText(e.Server, e.Channel, e.User, e.Message)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
.FirstOrDefault(m =>
|
.FirstOrDefault(m =>
|
||||||
m.RawText == GetText(e.Server, e.Channel, e.User, e.Before));
|
m.RawText == GetText(e.Server, e.Channel, e.User, e.Before));
|
||||||
if (msg != default(Message))
|
if (msg != default(Message))
|
||||||
await msg.Edit(GetText(e.Server, e.Channel, e.User, e.After));
|
await msg.Edit(GetText(e.Server, e.Channel, e.User, e.After)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (Subscribers.TryAdd(token, set))
|
if (Subscribers.TryAdd(token, set))
|
||||||
{
|
{
|
||||||
set.Add(e.Channel);
|
set.Add(e.Channel);
|
||||||
await e.User.SendMessage("This is your CSC token:" + token.ToString());
|
await e.User.SendMessage("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (!Subscribers.TryGetValue(token, out set))
|
if (!Subscribers.TryGetValue(token, out set))
|
||||||
return;
|
return;
|
||||||
set.Add(e.Channel);
|
set.Add(e.Channel);
|
||||||
await e.Channel.SendMessage(":ok:");
|
await e.Channel.SendMessage(":ok:").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "lcsc")
|
cgb.CreateCommand(Module.Prefix + "lcsc")
|
||||||
@ -103,7 +103,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
subscriber.Value.Remove(e.Channel);
|
subscriber.Value.Remove(e.Channel);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(":ok:");
|
await e.Channel.SendMessage(":ok:").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
sb.AppendLine($"`Name:` **#{server.Name}**");
|
sb.AppendLine($"`Name:` **#{server.Name}**");
|
||||||
sb.AppendLine($"`Owner:` **{server.Owner}**");
|
sb.AppendLine($"`Owner:` **{server.Owner}**");
|
||||||
sb.AppendLine($"`Id:` **{server.Id}**");
|
sb.AppendLine($"`Id:` **{server.Id}**");
|
||||||
sb.AppendLine($"`Icon Url:` **{await server.IconUrl.ShortenUrl()}**");
|
sb.AppendLine($"`Icon Url:` **{await server.IconUrl.ShortenUrl().ConfigureAwait(false)}**");
|
||||||
sb.AppendLine($"`TextChannels:` **{server.TextChannels.Count()}** `VoiceChannels:` **{server.VoiceChannels.Count()}**");
|
sb.AppendLine($"`TextChannels:` **{server.TextChannels.Count()}** `VoiceChannels:` **{server.VoiceChannels.Count()}**");
|
||||||
sb.AppendLine($"`Members:` **{server.UserCount}** `Online:` **{server.Users.Count(u => u.Status == UserStatus.Online)}** (may be incorrect)");
|
sb.AppendLine($"`Members:` **{server.UserCount}** `Online:` **{server.Users.Count(u => u.Status == UserStatus.Online)}** (may be incorrect)");
|
||||||
sb.AppendLine($"`Roles:` **{server.Roles.Count()}**");
|
sb.AppendLine($"`Roles:` **{server.Roles.Count()}**");
|
||||||
@ -44,7 +44,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
sb.AppendLine($"`Features:` **{string.Join(", ", server.Features)}**");
|
sb.AppendLine($"`Features:` **{string.Join(", ", server.Features)}**");
|
||||||
if (!string.IsNullOrWhiteSpace(server.SplashId))
|
if (!string.IsNullOrWhiteSpace(server.SplashId))
|
||||||
sb.AppendLine($"`Region:` **{server.Region.Name}**");
|
sb.AppendLine($"`Region:` **{server.Region.Name}**");
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "cinfo")
|
cgb.CreateCommand(Module.Prefix + "cinfo")
|
||||||
@ -66,7 +66,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
sb.AppendLine($"`Created At:` **{createdAt}**");
|
sb.AppendLine($"`Created At:` **{createdAt}**");
|
||||||
sb.AppendLine($"`Topic:` **{ch.Topic}**");
|
sb.AppendLine($"`Topic:` **{ch.Topic}**");
|
||||||
sb.AppendLine($"`Users:` **{ch.Users.Count()}**");
|
sb.AppendLine($"`Users:` **{ch.Users.Count()}**");
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "uinfo")
|
cgb.CreateCommand(Module.Prefix + "uinfo")
|
||||||
@ -87,8 +87,8 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
sb.AppendLine($"`Current Game:` **{(string.IsNullOrWhiteSpace(user.CurrentGame) ? "-" : user.CurrentGame)}**");
|
sb.AppendLine($"`Current Game:` **{(string.IsNullOrWhiteSpace(user.CurrentGame) ? "-" : user.CurrentGame)}**");
|
||||||
sb.AppendLine($"`Joined At:` **{user.JoinedAt}**");
|
sb.AppendLine($"`Joined At:` **{user.JoinedAt}**");
|
||||||
sb.AppendLine($"`Roles:` **({user.Roles.Count()}) - {string.Join(", ", user.Roles.Select(r => r.Name))}**");
|
sb.AppendLine($"`Roles:` **({user.Roles.Count()}) - {string.Join(", ", user.Roles.Select(r => r.Name))}**");
|
||||||
sb.AppendLine($"`AvatarUrl:` **{await user.AvatarUrl.ShortenUrl()}**");
|
sb.AppendLine($"`AvatarUrl:` **{await user.AvatarUrl.ShortenUrl().ConfigureAwait(false)}**");
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != e.User);
|
var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != e.User);
|
||||||
if (usr?.Status != UserStatus.Offline)
|
if (usr?.Status != UserStatus.Offline)
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage($"User `{usr.Name}` is offline. PM sent.");
|
await e.Channel.SendMessage($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false);
|
||||||
await usr.SendMessage(
|
await usr.SendMessage(
|
||||||
$"User `{e.User.Name}` mentioned you on " +
|
$"User `{e.User.Name}` mentioned you on " +
|
||||||
$"`{e.Server.Name}` server while you were offline.\n" +
|
$"`{e.Server.Name}` server while you were offline.\n" +
|
||||||
$"`Message:` {e.Message.Text}");
|
$"`Message:` {e.Message.Text}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
Channel ch;
|
Channel ch;
|
||||||
if (!logs.TryGetValue(e.Server, out ch))
|
if (!logs.TryGetValue(e.Server, out ch))
|
||||||
return;
|
return;
|
||||||
await ch.SendMessage($"`User banned:` **{e.User.Name}** ({e.User.Id})");
|
await ch.SendMessage($"`User banned:` **{e.User.Name}** ({e.User.Id})").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -63,11 +63,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (!logs.TryRemove(e.Server, out ch))
|
if (!logs.TryRemove(e.Server, out ch))
|
||||||
{
|
{
|
||||||
logs.TryAdd(e.Server, e.Channel);
|
logs.TryAdd(e.Server, e.Channel);
|
||||||
await e.Channel.SendMessage($"**I WILL BEGIN LOGGING SERVER ACTIVITY IN THIS CHANNEL**");
|
await e.Channel.SendMessage($"**I WILL BEGIN LOGGING SERVER ACTIVITY IN THIS CHANNEL**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage($"**NO LONGER LOGGING IN {ch.Mention} CHANNEL**");
|
await e.Channel.SendMessage($"**NO LONGER LOGGING IN {ch.Mention} CHANNEL**").ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
private async void MsgRecivd(object sender, MessageEventArgs e)
|
private async void MsgRecivd(object sender, MessageEventArgs e)
|
||||||
@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
Channel ch;
|
Channel ch;
|
||||||
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
||||||
return;
|
return;
|
||||||
await ch.SendMessage($"`Type:` **Message received** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}");
|
await ch.SendMessage($"`Type:` **Message received** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
Channel ch;
|
Channel ch;
|
||||||
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
||||||
return;
|
return;
|
||||||
await ch.SendMessage($"`Type:` **Message deleted** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}");
|
await ch.SendMessage($"`Type:` **Message deleted** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n`{e.User}:` {e.Message.Text}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
Channel ch;
|
Channel ch;
|
||||||
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
||||||
return;
|
return;
|
||||||
await ch.SendMessage($"`Type:` **Message updated** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n**BEFORE**: `{e.User}:` {e.Before.Text}\n---------------\n**AFTER**: `{e.User}:` {e.After.Text}");
|
await ch.SendMessage($"`Type:` **Message updated** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n**BEFORE**: `{e.User}:` {e.Before.Text}\n---------------\n**AFTER**: `{e.User}:` {e.After.Text}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (loggingPresences.TryGetValue(e.Server, out ch))
|
if (loggingPresences.TryGetValue(e.Server, out ch))
|
||||||
if (e.Before.Status != e.After.Status)
|
if (e.Before.Status != e.After.Status)
|
||||||
{
|
{
|
||||||
await ch.SendMessage($"**{e.Before.Name}** is now **{e.After.Status}**.");
|
await ch.SendMessage($"**{e.Before.Name}** is now **{e.After.Status}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@ -127,12 +127,12 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (e.Before.VoiceChannel != null && voiceChannelLog.ContainsKey(e.Before.VoiceChannel))
|
if (e.Before.VoiceChannel != null && voiceChannelLog.ContainsKey(e.Before.VoiceChannel))
|
||||||
{
|
{
|
||||||
if (e.After.VoiceChannel != e.Before.VoiceChannel)
|
if (e.After.VoiceChannel != e.Before.VoiceChannel)
|
||||||
await voiceChannelLog[e.Before.VoiceChannel].SendMessage($"🎼`{e.Before.Name} has left the` {e.Before.VoiceChannel.Mention} `voice channel.`");
|
await voiceChannelLog[e.Before.VoiceChannel].SendMessage($"🎼`{e.Before.Name} has left the` {e.Before.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
if (e.After.VoiceChannel != null && voiceChannelLog.ContainsKey(e.After.VoiceChannel))
|
if (e.After.VoiceChannel != null && voiceChannelLog.ContainsKey(e.After.VoiceChannel))
|
||||||
{
|
{
|
||||||
if (e.After.VoiceChannel != e.Before.VoiceChannel)
|
if (e.After.VoiceChannel != e.Before.VoiceChannel)
|
||||||
await voiceChannelLog[e.After.VoiceChannel].SendMessage($"🎼`{e.After.Name} has joined the`{e.After.VoiceChannel.Mention} `voice channel.`");
|
await voiceChannelLog[e.After.VoiceChannel].SendMessage($"🎼`{e.After.Name} has joined the`{e.After.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@ -149,7 +149,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
str += $"`New Avatar:` {e.After.AvatarUrl}";
|
str += $"`New Avatar:` {e.After.AvatarUrl}";
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
await ch.SendMessage(str);
|
await ch.SendMessage(str).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -167,10 +167,10 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
!specificConfig.SendPrivateMessageOnMention;
|
!specificConfig.SendPrivateMessageOnMention;
|
||||||
if (specificConfig.SendPrivateMessageOnMention)
|
if (specificConfig.SendPrivateMessageOnMention)
|
||||||
await e.Channel.SendMessage(":ok: I will send private messages " +
|
await e.Channel.SendMessage(":ok: I will send private messages " +
|
||||||
"to mentioned offline users.");
|
"to mentioned offline users.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage(":ok: I won't send private messages " +
|
await e.Channel.SendMessage(":ok: I won't send private messages " +
|
||||||
"to mentioned offline users anymore.");
|
"to mentioned offline users anymore.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "logserver")
|
cgb.CreateCommand(Module.Prefix + "logserver")
|
||||||
@ -189,11 +189,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (!loggingPresences.TryRemove(e.Server, out ch))
|
if (!loggingPresences.TryRemove(e.Server, out ch))
|
||||||
{
|
{
|
||||||
loggingPresences.TryAdd(e.Server, e.Channel);
|
loggingPresences.TryAdd(e.Server, e.Channel);
|
||||||
await e.Channel.SendMessage($"**User presence notifications enabled.**");
|
await e.Channel.SendMessage($"**User presence notifications enabled.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage($"**User presence notifications disabled.**");
|
await e.Channel.SendMessage($"**User presence notifications disabled.**").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "voicepresence")
|
cgb.CreateCommand(Module.Prefix + "voicepresence")
|
||||||
@ -210,23 +210,23 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
voiceChannelLog.TryAdd(voiceChannel, e.Channel);
|
voiceChannelLog.TryAdd(voiceChannel, e.Channel);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Started logging user presence for **ALL** voice channels!");
|
await e.Channel.SendMessage("Started logging user presence for **ALL** voice channels!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.User.VoiceChannel == null)
|
if (e.User.VoiceChannel == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 You are not in a voice channel right now. If you are, please rejoin it.");
|
await e.Channel.SendMessage("💢 You are not in a voice channel right now. If you are, please rejoin it.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Channel throwaway;
|
Channel throwaway;
|
||||||
if (!voiceChannelLog.TryRemove(e.User.VoiceChannel, out throwaway))
|
if (!voiceChannelLog.TryRemove(e.User.VoiceChannel, out throwaway))
|
||||||
{
|
{
|
||||||
voiceChannelLog.TryAdd(e.User.VoiceChannel, e.Channel);
|
voiceChannelLog.TryAdd(e.User.VoiceChannel, e.Channel);
|
||||||
await e.Channel.SendMessage($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`");
|
await e.Channel.SendMessage($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`");
|
await e.Channel.SendMessage($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,12 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (lastMessage != null)
|
if (lastMessage != null)
|
||||||
await lastMessage.Delete();
|
await lastMessage.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lastMessage = await ch.SendMessage(msg);
|
lastMessage = await ch.SendMessage(msg).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
// if both null, disable
|
// if both null, disable
|
||||||
if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Repeating disabled");
|
await e.Channel.SendMessage("Repeating disabled").ConfigureAwait(false);
|
||||||
Repeater rep;
|
Repeater rep;
|
||||||
if (repeaters.TryGetValue(e.Server, out rep))
|
if (repeaters.TryGetValue(e.Server, out rep))
|
||||||
rep.MessageTimer.Stop();
|
rep.MessageTimer.Stop();
|
||||||
@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
int minutes;
|
int minutes;
|
||||||
if (!int.TryParse(minutesStr, out minutes) || minutes < 1 || minutes > 720)
|
if (!int.TryParse(minutesStr, out minutes) || minutes < 1 || minutes > 720)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Invalid value");
|
await e.Channel.SendMessage("Invalid value").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,8 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
await e.Channel.SendMessage(String.Format("👌 Repeating `{0}` every " +
|
await e.Channel.SendMessage(String.Format("👌 Repeating `{0}` every " +
|
||||||
"**{1}** minutes on {2} channel.",
|
"**{1}** minutes on {2} channel.",
|
||||||
repeater.RepeatingMessage, minutes, repeater.RepeatingChannel));
|
repeater.RepeatingMessage, minutes, repeater.RepeatingChannel))
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Classes.JSONModels;
|
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
|
using NadekoBot.Classes.JSONModels;
|
||||||
using NadekoBot.Modules.Music;
|
using NadekoBot.Modules.Music;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
using System;
|
||||||
@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
NadekoBot.Config.IsRotatingStatus = timer.Enabled;
|
NadekoBot.Config.IsRotatingStatus = timer.Enabled;
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`");
|
await e.Channel.SendMessage($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`").ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
internal override void Init(CommandGroupBuilder cgb)
|
||||||
@ -108,7 +108,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
NadekoBot.Config.RotatingStatuses.Add(arg);
|
NadekoBot.Config.RotatingStatuses.Add(arg);
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("🆗 `Added a new playing string.`");
|
await e.Channel.SendMessage("🆗 `Added a new playing string.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "listplaying")
|
cgb.CreateCommand(Module.Prefix + "listplaying")
|
||||||
@ -119,13 +119,13 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
if (NadekoBot.Config.RotatingStatuses.Count == 0)
|
if (NadekoBot.Config.RotatingStatuses.Count == 0)
|
||||||
await e.Channel.SendMessage("`There are no playing strings. " +
|
await e.Channel.SendMessage("`There are no playing strings. " +
|
||||||
"Add some with .addplaying [text] command.`");
|
"Add some with .addplaying [text] command.`").ConfigureAwait(false);
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
for (var i = 0; i < NadekoBot.Config.RotatingStatuses.Count; i++)
|
for (var i = 0; i < NadekoBot.Config.RotatingStatuses.Count; i++)
|
||||||
{
|
{
|
||||||
sb.AppendLine($"`{i + 1}.` {NadekoBot.Config.RotatingStatuses[i]}");
|
sb.AppendLine($"`{i + 1}.` {NadekoBot.Config.RotatingStatuses[i]}");
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "removeplaying")
|
cgb.CreateCommand(Module.Prefix + "removeplaying")
|
||||||
@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
NadekoBot.Config.RotatingStatuses.RemoveAt(num - 1);
|
NadekoBot.Config.RotatingStatuses.RemoveAt(num - 1);
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"🆗 `Removed playing string #{num}`({str})");
|
await e.Channel.SendMessage($"🆗 `Removed playing string #{num}`({str})").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Message.Delete();
|
await e.Message.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
return;
|
return;
|
||||||
@ -54,13 +54,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
ConcurrentDictionary<ulong, DateTime> throwaway;
|
ConcurrentDictionary<ulong, DateTime> throwaway;
|
||||||
if (RatelimitingChannels.TryRemove(e.Channel.Id, out throwaway))
|
if (RatelimitingChannels.TryRemove(e.Channel.Id, out throwaway))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Slow mode disabled.");
|
await e.Channel.SendMessage("Slow mode disabled.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (RatelimitingChannels.TryAdd(e.Channel.Id, new ConcurrentDictionary<ulong, DateTime>()))
|
if (RatelimitingChannels.TryAdd(e.Channel.Id, new ConcurrentDictionary<ulong, DateTime>()))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Slow mode initiated. " +
|
await e.Channel.SendMessage("Slow mode initiated. " +
|
||||||
"Users can't send more than 1 message every 5 seconds.");
|
"Users can't send more than 1 message every 5 seconds.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
ch = NadekoBot.Client.PrivateChannels.FirstOrDefault(c => (long)c.Id == r.ChannelId);
|
ch = NadekoBot.Client.PrivateChannels.FirstOrDefault(c => (long)c.Id == r.ChannelId);
|
||||||
if (ch == null)
|
if (ch == null)
|
||||||
ch = await NadekoBot.Client.CreatePrivateChannel((ulong)r.ChannelId);
|
ch = await NadekoBot.Client.CreatePrivateChannel((ulong)r.ChannelId).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ch = NadekoBot.Client.GetServer((ulong)r.ServerId)?.GetChannel((ulong)r.ChannelId);
|
ch = NadekoBot.Client.GetServer((ulong)r.ServerId)?.GetChannel((ulong)r.ChannelId);
|
||||||
@ -53,7 +53,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (ch == null)
|
if (ch == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await ch.SendMessage($"❗⏰**I've been told to remind you to '{r.Message}' now by <@{r.UserId}>.**⏰❗");
|
await ch.SendMessage($"❗⏰**I've been told to remind you to '{r.Message}' now by <@{r.UserId}>.**⏰❗").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (meorchStr == "ME")
|
if (meorchStr == "ME")
|
||||||
{
|
{
|
||||||
isPrivate = true;
|
isPrivate = true;
|
||||||
ch = await e.User.CreatePMChannel();
|
ch = await e.User.CreatePMChannel().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else if (meorchStr == "HERE")
|
else if (meorchStr == "HERE")
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
if (ch == null)
|
if (ch == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} Something went wrong (channel cannot be found) ;(");
|
await e.Channel.SendMessage($"{e.User.Mention} Something went wrong (channel cannot be found) ;(").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
if (m.Length == 0)
|
if (m.Length == 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Not a valid time format blablabla");
|
await e.Channel.SendMessage("Not a valid time format blablabla").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
(groupName == "hours" && value > 23) ||
|
(groupName == "hours" && value > 23) ||
|
||||||
(groupName == "minutes" && value > 59))
|
(groupName == "minutes" && value > 59))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"Invalid {groupName} value.");
|
await e.Channel.SendMessage($"Invalid {groupName} value.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -163,7 +163,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
reminders.Add(StartNewReminder(rem));
|
reminders.Add(StartNewReminder(rem));
|
||||||
|
|
||||||
await e.Channel.SendMessage($"⏰ I will remind \"{ch.Name}\" to \"{e.GetArg("message").ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:m})");
|
await e.Channel.SendMessage($"⏰ I will remind \"{ch.Name}\" to \"{e.GetArg("message").ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:m})").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
msg.AppendLine($":ok:Role **{role.Name}** added to the list.");
|
msg.AppendLine($":ok:Role **{role.Name}** added to the list.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(msg.ToString());
|
await e.Channel.SendMessage(msg.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".rsar")
|
cgb.CreateCommand(".rsar")
|
||||||
@ -52,17 +52,17 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger:That role does not exist.");
|
await e.Channel.SendMessage(":anger:That role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger:That role is not self-assignable.");
|
await e.Channel.SendMessage(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
config.ListOfSelfAssignableRoles.Remove(role.Id);
|
config.ListOfSelfAssignableRoles.Remove(role.Id);
|
||||||
await e.Channel.SendMessage($":ok:**{role.Name}** has been removed from the list of self-assignable roles");
|
await e.Channel.SendMessage($":ok:**{role.Name}** has been removed from the list of self-assignable roles").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".lsar")
|
cgb.CreateCommand(".lsar")
|
||||||
@ -90,7 +90,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
config.ListOfSelfAssignableRoles.Remove(id);
|
config.ListOfSelfAssignableRoles.Remove(id);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(msg.ToString());
|
await e.Channel.SendMessage(msg.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".iam")
|
cgb.CreateCommand(".iam")
|
||||||
@ -106,22 +106,22 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger:That role does not exist.");
|
await e.Channel.SendMessage(":anger:That role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger:That role is not self-assignable.");
|
await e.Channel.SendMessage(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.User.HasRole(role))
|
if (e.User.HasRole(role))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($":anger:You already have {role.Name} role.");
|
await e.Channel.SendMessage($":anger:You already have {role.Name} role.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.User.AddRoles(role);
|
await e.User.AddRoles(role).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($":ok:You now have {role.Name} role.");
|
await e.Channel.SendMessage($":ok:You now have {role.Name} role.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".iamn")
|
cgb.CreateCommand(".iamn")
|
||||||
@ -138,22 +138,22 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger:That role does not exist.");
|
await e.Channel.SendMessage(":anger:That role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
if (!config.ListOfSelfAssignableRoles.Contains(role.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger:That role is not self-assignable.");
|
await e.Channel.SendMessage(":anger:That role is not self-assignable.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!e.User.HasRole(role))
|
if (!e.User.HasRole(role))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($":anger:You don't have {role.Name} role.");
|
await e.Channel.SendMessage($":anger:You don't have {role.Name} role.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.User.RemoveRoles(role);
|
await e.User.RemoveRoles(role).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($":ok:Successfuly removed {role.Name} role from you.");
|
await e.Channel.SendMessage($":ok:Successfuly removed {role.Name} role from you.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
Greeted++;
|
Greeted++;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.User.SendMessage($"`Farewell Message From {e.Server?.Name}`\n" + msg);
|
await e.User.SendMessage($"`Farewell Message From {e.Server?.Name}`\n" + msg).ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@ -68,11 +68,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
if (channel == null) return;
|
if (channel == null) return;
|
||||||
Greeted++;
|
Greeted++;
|
||||||
var toDelete = await channel.SendMessage(msg);
|
var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages)
|
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(300000); // 5 minutes
|
await Task.Delay(300000).ConfigureAwait(false); // 5 minutes
|
||||||
await toDelete.Delete();
|
await toDelete.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,17 +95,17 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (controls.GreetPM)
|
if (controls.GreetPM)
|
||||||
{
|
{
|
||||||
Greeted++;
|
Greeted++;
|
||||||
await e.User.SendMessage($"`Welcome Message From {e.Server.Name}`\n" + msg);
|
await e.User.SendMessage($"`Welcome Message From {e.Server.Name}`\n" + msg).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (channel == null) return;
|
if (channel == null) return;
|
||||||
Greeted++;
|
Greeted++;
|
||||||
var toDelete = await channel.SendMessage(msg);
|
var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages)
|
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(300000); // 5 minutes
|
await Task.Delay(300000).ConfigureAwait(false); // 5 minutes
|
||||||
await toDelete.Delete();
|
await toDelete.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,9 +219,9 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
var controls = AnnouncementsDictionary[e.Server.Id];
|
var controls = AnnouncementsDictionary[e.Server.Id];
|
||||||
|
|
||||||
if (controls.ToggleGreet(e.Channel.Id))
|
if (controls.ToggleGreet(e.Channel.Id))
|
||||||
await e.Channel.SendMessage("Greet announcements enabled on this channel.");
|
await e.Channel.SendMessage("Greet announcements enabled on this channel.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("Greet announcements disabled.");
|
await e.Channel.SendMessage("Greet announcements disabled.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "greetmsg")
|
cgb.CreateCommand(Module.Prefix + "greetmsg")
|
||||||
@ -235,9 +235,9 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
|
|
||||||
AnnouncementsDictionary[e.Server.Id].GreetText = e.GetArg("msg");
|
AnnouncementsDictionary[e.Server.Id].GreetText = e.GetArg("msg");
|
||||||
await e.Channel.SendMessage("New greet message set.");
|
await e.Channel.SendMessage("New greet message set.").ConfigureAwait(false);
|
||||||
if (!AnnouncementsDictionary[e.Server.Id].Greet)
|
if (!AnnouncementsDictionary[e.Server.Id].Greet)
|
||||||
await e.Channel.SendMessage("Enable greet messsages by typing `.greet`");
|
await e.Channel.SendMessage("Enable greet messsages by typing `.greet`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "bye")
|
cgb.CreateCommand(Module.Prefix + "bye")
|
||||||
@ -251,9 +251,9 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
var controls = AnnouncementsDictionary[e.Server.Id];
|
var controls = AnnouncementsDictionary[e.Server.Id];
|
||||||
|
|
||||||
if (controls.ToggleBye(e.Channel.Id))
|
if (controls.ToggleBye(e.Channel.Id))
|
||||||
await e.Channel.SendMessage("Bye announcements enabled on this channel.");
|
await e.Channel.SendMessage("Bye announcements enabled on this channel.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("Bye announcements disabled.");
|
await e.Channel.SendMessage("Bye announcements disabled.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "byemsg")
|
cgb.CreateCommand(Module.Prefix + "byemsg")
|
||||||
@ -267,9 +267,9 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
|
|
||||||
AnnouncementsDictionary[e.Server.Id].ByeText = e.GetArg("msg");
|
AnnouncementsDictionary[e.Server.Id].ByeText = e.GetArg("msg");
|
||||||
await e.Channel.SendMessage("New bye message set.");
|
await e.Channel.SendMessage("New bye message set.").ConfigureAwait(false);
|
||||||
if (!AnnouncementsDictionary[e.Server.Id].Bye)
|
if (!AnnouncementsDictionary[e.Server.Id].Bye)
|
||||||
await e.Channel.SendMessage("Enable bye messsages by typing `.bye`.");
|
await e.Channel.SendMessage("Enable bye messsages by typing `.bye`.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "byepm")
|
cgb.CreateCommand(Module.Prefix + "byepm")
|
||||||
@ -282,11 +282,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
AnnouncementsDictionary[e.Server.Id].ToggleByePM();
|
AnnouncementsDictionary[e.Server.Id].ToggleByePM();
|
||||||
if (AnnouncementsDictionary[e.Server.Id].ByePM)
|
if (AnnouncementsDictionary[e.Server.Id].ByePM)
|
||||||
await e.Channel.SendMessage("Bye messages will be sent in a PM from now on.\n ⚠ Keep in mind this might fail if the user and the bot have no common servers after the user leaves.");
|
await e.Channel.SendMessage("Bye messages will be sent in a PM from now on.\n ⚠ Keep in mind this might fail if the user and the bot have no common servers after the user leaves.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("Bye messages will be sent in a bound channel from now on.");
|
await e.Channel.SendMessage("Bye messages will be sent in a bound channel from now on.").ConfigureAwait(false);
|
||||||
if (!AnnouncementsDictionary[e.Server.Id].Bye)
|
if (!AnnouncementsDictionary[e.Server.Id].Bye)
|
||||||
await e.Channel.SendMessage("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`");
|
await e.Channel.SendMessage("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "greetpm")
|
cgb.CreateCommand(Module.Prefix + "greetpm")
|
||||||
@ -299,11 +299,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
AnnouncementsDictionary[e.Server.Id].ToggleGreetPM();
|
AnnouncementsDictionary[e.Server.Id].ToggleGreetPM();
|
||||||
if (AnnouncementsDictionary[e.Server.Id].GreetPM)
|
if (AnnouncementsDictionary[e.Server.Id].GreetPM)
|
||||||
await e.Channel.SendMessage("Greet messages will be sent in a PM from now on.");
|
await e.Channel.SendMessage("Greet messages will be sent in a PM from now on.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("Greet messages will be sent in a bound channel from now on.");
|
await e.Channel.SendMessage("Greet messages will be sent in a bound channel from now on.").ConfigureAwait(false);
|
||||||
if (!AnnouncementsDictionary[e.Server.Id].Greet)
|
if (!AnnouncementsDictionary[e.Server.Id].Greet)
|
||||||
await e.Channel.SendMessage("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`");
|
await e.Channel.SendMessage("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,12 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
return;
|
return;
|
||||||
if (subscribers.ContainsKey(voiceChannel))
|
if (subscribers.ContainsKey(voiceChannel))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("`Voice channel notifications disabled.`");
|
await e.Channel.SendMessage("`Voice channel notifications disabled.`").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (subscribers.TryAdd(voiceChannel, e.Channel))
|
if (subscribers.TryAdd(voiceChannel, e.Channel))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("`Voice channel notifications enabled.`");
|
await e.Channel.SendMessage("`Voice channel notifications enabled.`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
await e.Server.Owner.SendMessage(
|
await e.Server.Owner.SendMessage(
|
||||||
"I don't have manage server and/or Manage Channels permission," +
|
"I don't have manage server and/or Manage Channels permission," +
|
||||||
$" so I cannot run voice+text on **{e.Server.Name}** server.");
|
$" so I cannot run voice+text on **{e.Server.Name}** server.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { } // meh
|
catch { } // meh
|
||||||
config.VoicePlusTextEnabled = false;
|
config.VoicePlusTextEnabled = false;
|
||||||
@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
if (textChannel != null)
|
if (textChannel != null)
|
||||||
await textChannel.AddPermissionsRule(e.Before,
|
await textChannel.AddPermissionsRule(e.Before,
|
||||||
new ChPermOverride(readMessages: PermValue.Deny,
|
new ChPermOverride(readMessages: PermValue.Deny,
|
||||||
sendMessages: PermValue.Deny));
|
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
var afterVch = e.After.VoiceChannel;
|
var afterVch = e.After.VoiceChannel;
|
||||||
if (afterVch != null)
|
if (afterVch != null)
|
||||||
@ -61,14 +61,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
if (textChannel == null)
|
if (textChannel == null)
|
||||||
{
|
{
|
||||||
textChannel = (await e.Server.CreateChannel(GetChannelName(afterVch.Name), ChannelType.Text));
|
textChannel = (await e.Server.CreateChannel(GetChannelName(afterVch.Name), ChannelType.Text).ConfigureAwait(false));
|
||||||
await textChannel.AddPermissionsRule(e.Server.EveryoneRole,
|
await textChannel.AddPermissionsRule(e.Server.EveryoneRole,
|
||||||
new ChPermOverride(readMessages: PermValue.Deny,
|
new ChPermOverride(readMessages: PermValue.Deny,
|
||||||
sendMessages: PermValue.Deny));
|
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await textChannel.AddPermissionsRule(e.After,
|
await textChannel.AddPermissionsRule(e.After,
|
||||||
new ChPermOverride(readMessages: PermValue.Allow,
|
new ChPermOverride(readMessages: PermValue.Allow,
|
||||||
sendMessages: PermValue.Allow));
|
sendMessages: PermValue.Allow)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -101,27 +101,28 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await textChannel.Delete();
|
await textChannel.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await
|
await e.Channel.SendMessage(
|
||||||
e.Channel.SendMessage(
|
":anger: Error: Most likely i don't have permissions to do this.")
|
||||||
":anger: Error: Most likely i don't have permissions to do this.");
|
.ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Successfuly removed voice + text feature.");
|
await e.Channel.SendMessage("Successfuly removed voice + text feature.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
config.VoicePlusTextEnabled = true;
|
config.VoicePlusTextEnabled = true;
|
||||||
await e.Channel.SendMessage("Successfuly enabled voice + text feature. " +
|
await e.Channel.SendMessage("Successfuly enabled voice + text feature. " +
|
||||||
"**Make sure the bot has manage roles and manage channels permissions**");
|
"**Make sure the bot has manage roles and manage channels permissions**")
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(ex.ToString());
|
await e.Channel.SendMessage(ex.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ namespace NadekoBot.Classes.ClashOfClans
|
|||||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
#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 ClearArray()).ConfigureAwait(false);
|
Task.Run(async () => await ClearArray()).ConfigureAwait(false);
|
||||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
await Task.Delay(new TimeSpan(24, 0, 0), endTokenSource.Token);
|
await Task.Delay(new TimeSpan(24, 0, 0), endTokenSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
finally
|
finally
|
||||||
@ -115,7 +115,7 @@ namespace NadekoBot.Classes.ClashOfClans
|
|||||||
{
|
{
|
||||||
while (!endTokenSource.IsCancellationRequested)
|
while (!endTokenSource.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
await Task.Delay(5000);
|
await Task.Delay(5000).ConfigureAwait(false);
|
||||||
for (var i = 0; i < bases.Length; i++)
|
for (var i = 0; i < bases.Length; i++)
|
||||||
{
|
{
|
||||||
if (bases[i] == null) continue;
|
if (bases[i] == null) continue;
|
||||||
|
@ -46,7 +46,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
int size;
|
int size;
|
||||||
if (!int.TryParse(e.GetArg("size"), out size) || size < 10 || size > 50 || size % 5 != 0)
|
if (!int.TryParse(e.GetArg("size"), out size) || size < 10 || size > 50 || size % 5 != 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 Not a Valid war size");
|
await e.Channel.SendMessage("💢🔰 Not a Valid war size").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var cw = new ClashWar(enemyClan, size, e);
|
var cw = new ClashWar(enemyClan, size, e);
|
||||||
@ -58,7 +58,8 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
{
|
{
|
||||||
await
|
await
|
||||||
e.Channel.SendMessage(
|
e.Channel.SendMessage(
|
||||||
$"❗🔰**Claim from @{u} for a war against {cw.ShortPrint()} has expired.**");
|
$"❗🔰**Claim from @{u} for a war against {cw.ShortPrint()} has expired.**")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
@ -66,11 +67,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**");
|
await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
await e.Channel.SendMessage($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**");
|
await e.Channel.SendMessage($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**").ConfigureAwait(false);
|
||||||
//war with the index X started.
|
//war with the index X started.
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -83,19 +84,19 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null)
|
if (warsInfo == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var war = warsInfo.Item1[warsInfo.Item2];
|
var war = warsInfo.Item1[warsInfo.Item2];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var startTask = war.Start();
|
var startTask = war.Start();
|
||||||
await e.Channel.SendMessage($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**");
|
await e.Channel.SendMessage($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**").ConfigureAwait(false);
|
||||||
await startTask;
|
await startTask.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"🔰**WAR AGAINST {war.ShortPrint()} IS ALREADY STARTED**");
|
await e.Channel.SendMessage($"🔰**WAR AGAINST {war.ShortPrint()} IS ALREADY STARTED**").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
ClashWars.TryGetValue(e.Server.Id, out wars);
|
ClashWars.TryGetValue(e.Server.Id, out wars);
|
||||||
if (wars == null || wars.Count == 0)
|
if (wars == null || wars.Count == 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("🔰 **No active wars.**");
|
await e.Channel.SendMessage("🔰 **No active wars.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,17 +127,17 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**");
|
sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**");
|
||||||
sb.AppendLine("**-------------------------**");
|
sb.AppendLine("**-------------------------**");
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if number is not null, print the war needed
|
//if number is not null, print the war needed
|
||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null)
|
if (warsInfo == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(warsInfo.Item1[warsInfo.Item2].ToString());
|
await e.Channel.SendMessage(warsInfo.Item1[warsInfo.Item2].ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "claim")
|
cgb.CreateCommand(Prefix + "claim")
|
||||||
@ -151,13 +152,13 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int baseNum;
|
int baseNum;
|
||||||
if (!int.TryParse(e.GetArg("baseNumber"), out baseNum))
|
if (!int.TryParse(e.GetArg("baseNumber"), out baseNum))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **Invalid base number.**");
|
await e.Channel.SendMessage("💢🔰 **Invalid base number.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var usr =
|
var usr =
|
||||||
@ -168,11 +169,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
{
|
{
|
||||||
var war = warsInfo.Item1[warsInfo.Item2];
|
var war = warsInfo.Item1[warsInfo.Item2];
|
||||||
war.Call(usr, baseNum - 1);
|
war.Call(usr, baseNum - 1);
|
||||||
await e.Channel.SendMessage($"🔰**{usr}** claimed a base #{baseNum} for a war against {war.ShortPrint()}");
|
await e.Channel.SendMessage($"🔰**{usr}** claimed a base #{baseNum} for a war against {war.ShortPrint()}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
await e.Channel.SendMessage($"💢🔰 {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
var warInfo = GetInfo(e);
|
var warInfo = GetInfo(e);
|
||||||
if (warInfo == null || warInfo.Item1.Count == 0)
|
if (warInfo == null || warInfo.Item1.Count == 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var usr =
|
var usr =
|
||||||
@ -198,11 +199,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var baseNum = war.FinishClaim(usr);
|
var baseNum = war.FinishClaim(usr);
|
||||||
await e.Channel.SendMessage($"❗🔰{e.User.Mention} **DESTROYED** a base #{baseNum + 1} in a war against {war.ShortPrint()}");
|
await e.Channel.SendMessage($"❗🔰{e.User.Mention} **DESTROYED** a base #{baseNum + 1} in a war against {war.ShortPrint()}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
await e.Channel.SendMessage($"💢🔰 {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -217,7 +218,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var usr =
|
var usr =
|
||||||
@ -228,11 +229,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
{
|
{
|
||||||
var war = warsInfo.Item1[warsInfo.Item2];
|
var war = warsInfo.Item1[warsInfo.Item2];
|
||||||
var baseNumber = war.Uncall(usr);
|
var baseNumber = war.Uncall(usr);
|
||||||
await e.Channel.SendMessage($"🔰 @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}");
|
await e.Channel.SendMessage($"🔰 @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
await e.Channel.SendMessage($"💢🔰 {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -245,7 +246,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
|||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null)
|
if (warsInfo == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 That war does not exist.");
|
await e.Channel.SendMessage("💢🔰 That war does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
warsInfo.Item1[warsInfo.Item2].End();
|
warsInfo.Item1[warsInfo.Item2].End();
|
||||||
|
@ -24,7 +24,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
return;
|
return;
|
||||||
if (CopiedUsers.Contains(e.User.Id))
|
if (CopiedUsers.Contains(e.User.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.Message.Text);
|
await e.Channel.SendMessage(e.Message.Text).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@ -35,7 +35,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
if (CopiedUsers.Contains(e.User.Id)) return;
|
if (CopiedUsers.Contains(e.User.Id)) return;
|
||||||
|
|
||||||
CopiedUsers.Add(e.User.Id);
|
CopiedUsers.Add(e.User.Id);
|
||||||
await e.Channel.SendMessage(" I'll start copying you now.");
|
await e.Channel.SendMessage(" I'll start copying you now.").ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
internal override void Init(CommandGroupBuilder cgb)
|
||||||
@ -56,7 +56,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
if (!CopiedUsers.Contains(e.User.Id)) return;
|
if (!CopiedUsers.Contains(e.User.Id)) return;
|
||||||
|
|
||||||
CopiedUsers.Remove(e.User.Id);
|
CopiedUsers.Remove(e.User.Id);
|
||||||
await e.Channel.SendMessage(" I wont copy anymore.");
|
await e.Channel.SendMessage(" I wont copy anymore.").ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,21 +61,21 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went wrong.");
|
await e.Channel.SendMessage("Something went wrong.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Thank you for your request.");
|
await e.Channel.SendMessage("Thank you for your request.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("lr")
|
cgb.CreateCommand("lr")
|
||||||
.Description("PMs the user all current nadeko requests.")
|
.Description("PMs the user all current nadeko requests.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var str = await Task.Run(() => GetRequests());
|
var str = await Task.Run(() => GetRequests()).ConfigureAwait(false);
|
||||||
if (str.Trim().Length > 110)
|
if (str.Trim().Length > 110)
|
||||||
await e.User.Send(str);
|
await e.User.Send(str).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.User.Send("No requests atm.");
|
await e.User.Send("No requests atm.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("dr")
|
cgb.CreateCommand("dr")
|
||||||
@ -89,19 +89,19 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
{
|
{
|
||||||
if (DeleteRequest(int.Parse(e.Args[0])))
|
if (DeleteRequest(int.Parse(e.Args[0])))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " Request deleted.");
|
await e.Channel.SendMessage(e.User.Mention + " Request deleted.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("No request on that number.");
|
await e.Channel.SendMessage("No request on that number.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error deleting request, probably NaN error.");
|
await e.Channel.SendMessage("Error deleting request, probably NaN error.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else await e.Channel.SendMessage("You don't have permission to do that.");
|
else await e.Channel.SendMessage("You don't have permission to do that.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("rr")
|
cgb.CreateCommand("rr")
|
||||||
@ -116,20 +116,20 @@ namespace NadekoBot.Classes.Conversations.Commands
|
|||||||
var sc = ResolveRequest(int.Parse(e.Args[0]));
|
var sc = ResolveRequest(int.Parse(e.Args[0]));
|
||||||
if (sc != null)
|
if (sc != null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " Request resolved, notice sent.");
|
await e.Channel.SendMessage(e.User.Mention + " Request resolved, notice sent.").ConfigureAwait(false);
|
||||||
await NadekoBot.Client.GetServer((ulong)sc.ServerId).GetUser((ulong)sc.UserId).Send("**This request of yours has been resolved:**\n" + sc.RequestText);
|
await NadekoBot.Client.GetServer((ulong)sc.ServerId).GetUser((ulong)sc.UserId).Send("**This request of yours has been resolved:**\n" + sc.RequestText).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("No request on that number.");
|
await e.Channel.SendMessage("No request on that number.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error resolving request, probably NaN error.");
|
await e.Channel.SendMessage("Error resolving request, probably NaN error.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else await e.Channel.SendMessage("You don't have permission to do that.");
|
else await e.Channel.SendMessage("You don't have permission to do that.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
var other = e.GetArg("other");
|
var other = e.GetArg("other");
|
||||||
if (string.IsNullOrWhiteSpace(other))
|
if (string.IsNullOrWhiteSpace(other))
|
||||||
await e.Channel.SendMessage($"{e.User.Name} did it. 😒 🔫");
|
await e.Channel.SendMessage($"{e.User.Name} did it. 😒 🔫").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage($"{other} did it. 😒 🔫");
|
await e.Channel.SendMessage($"{other} did it. 😒 🔫").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("comeatmebro")
|
cgb.CreateCommand("comeatmebro")
|
||||||
@ -54,28 +54,25 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
|
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("(ง’̀-‘́)ง");
|
await e.Channel.SendMessage("(ง’̀-‘́)ง").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"{usr.Mention} (ง’̀-‘́)ง");
|
await e.Channel.SendMessage($"{usr.Mention} (ง’̀-‘́)ง").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
cgb.CreateCommand("\\o\\")
|
cgb.CreateCommand("\\o\\")
|
||||||
.Description("Nadeko replies with /o/")
|
.Description("Nadeko replies with /o/")
|
||||||
.Do(async e => await e.Channel.SendMessage(e.User.Mention + "/o/"));
|
.Do(async e => await e.Channel.SendMessage(e.User.Mention + "/o/").ConfigureAwait(false));
|
||||||
|
|
||||||
cgb.CreateCommand("/o/")
|
cgb.CreateCommand("/o/")
|
||||||
.Description("Nadeko replies with \\o\\")
|
.Description("Nadeko replies with \\o\\")
|
||||||
.Do(async e => await e.Channel.SendMessage(e.User.Mention + "\\o\\"));
|
.Do(async e => await e.Channel.SendMessage(e.User.Mention + "\\o\\").ConfigureAwait(false));
|
||||||
|
|
||||||
cgb.CreateCommand("moveto")
|
cgb.CreateCommand("moveto")
|
||||||
.Description("Suggests moving the conversation.\n**Usage**: moveto #spam")
|
.Description("Suggests moving the conversation.\n**Usage**: moveto #spam")
|
||||||
.Parameter("target", ParameterType.Unparsed)
|
.Parameter("target", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e => await e.Channel.SendMessage($"(👉 ͡° ͜ʖ ͡°)👉 {e.GetArg("target")}"));
|
||||||
{
|
|
||||||
await e.Channel.SendMessage($"(👉 ͡° ͜ʖ ͡°)👉 {e.GetArg("target")}");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
cgb.CreateCommand("..")
|
cgb.CreateCommand("..")
|
||||||
@ -94,9 +91,9 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
Keyword = e.GetArg("keyword").ToLowerInvariant(),
|
Keyword = e.GetArg("keyword").ToLowerInvariant(),
|
||||||
Text = text,
|
Text = text,
|
||||||
UserName = e.User.Name,
|
UserName = e.User.Name,
|
||||||
}));
|
})).ConfigureAwait(false);
|
||||||
|
|
||||||
await e.Channel.SendMessage("`New quote added.`");
|
await e.Channel.SendMessage("`New quote added.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("...")
|
cgb.CreateCommand("...")
|
||||||
@ -113,9 +110,9 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
uqm => uqm.Keyword == keyword);
|
uqm => uqm.Keyword == keyword);
|
||||||
|
|
||||||
if (quote != null)
|
if (quote != null)
|
||||||
await e.Channel.SendMessage($"📣 {quote.Text}");
|
await e.Channel.SendMessage($"📣 {quote.Text}").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("💢`No quote found.`");
|
await e.Channel.SendMessage("💢`No quote found.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -133,7 +130,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
var time = (DateTime.Now - Process.GetCurrentProcess().StartTime);
|
var time = (DateTime.Now - Process.GetCurrentProcess().StartTime);
|
||||||
var str = string.Format("I have been running for {0} days, {1} hours, and {2} minutes.", time.Days, time.Hours, time.Minutes);
|
var str = string.Format("I have been running for {0} days, {1} hours, and {2} minutes.", time.Days, time.Hours, time.Minutes);
|
||||||
await e.Channel.SendMessage(str);
|
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("die")
|
cgb.CreateCommand("die")
|
||||||
@ -142,12 +139,12 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
if (NadekoBot.IsOwner(e.User.Id))
|
if (NadekoBot.IsOwner(e.User.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + ", Yes, my love.");
|
await e.Channel.SendMessage(e.User.Mention + ", Yes, my love.").ConfigureAwait(false);
|
||||||
await Task.Delay(5000);
|
await Task.Delay(5000).ConfigureAwait(false);
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage(e.User.Mention + ", No.");
|
await e.Channel.SendMessage(e.User.Mention + ", No.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
var randServerSw = new Stopwatch();
|
var randServerSw = new Stopwatch();
|
||||||
@ -158,9 +155,9 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (NadekoBot.IsOwner(e.User.Id))
|
if (NadekoBot.IsOwner(e.User.Id))
|
||||||
await e.Channel.SendMessage(e.User.Mention + ", Of course I do, my Master.");
|
await e.Channel.SendMessage(e.User.Mention + ", Of course I do, my Master.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage(e.User.Mention + ", Don't be silly.");
|
await e.Channel.SendMessage(e.User.Mention + ", Don't be silly.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("how are you")
|
cgb.CreateCommand("how are you")
|
||||||
@ -170,17 +167,17 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
if (NadekoBot.IsOwner(e.User.Id))
|
if (NadekoBot.IsOwner(e.User.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " I am great as long as you are here.");
|
await e.Channel.SendMessage(e.User.Mention + " I am great as long as you are here.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var kw = e.Server.GetUser(NadekoBot.Creds.OwnerIds[0]);
|
var kw = e.Server.GetUser(NadekoBot.Creds.OwnerIds[0]);
|
||||||
if (kw != null && kw.Status == UserStatus.Online)
|
if (kw != null && kw.Status == UserStatus.Online)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " I am great as long as " + kw.Mention + " is with me.");
|
await e.Channel.SendMessage(e.User.Mention + " I am great as long as " + kw.Mention + " is with me.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " I am sad. My Master is not with me.");
|
await e.Channel.SendMessage(e.User.Mention + " I am sad. My Master is not with me.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -192,16 +189,16 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
|
var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
|
||||||
if (u == null)
|
if (u == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Invalid user specified.");
|
await e.Channel.SendMessage("Invalid user specified.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NadekoBot.IsOwner(u.Id))
|
if (NadekoBot.IsOwner(u.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("I would never insult my master <3");
|
await e.Channel.SendMessage("I would never insult my master <3").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(u.Mention + NadekoBot.Locale.Insults[rng.Next(0, NadekoBot.Locale.Insults.Length)]);
|
await e.Channel.SendMessage(u.Mention + NadekoBot.Locale.Insults[rng.Next(0, NadekoBot.Locale.Insults.Length)]).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("praise")
|
cgb.CreateCommand("praise")
|
||||||
@ -213,16 +210,16 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
|
|
||||||
if (u == null)
|
if (u == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Invalid user specified.");
|
await e.Channel.SendMessage("Invalid user specified.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NadekoBot.IsOwner(u.Id))
|
if (NadekoBot.IsOwner(u.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " I don't need your permission to praise my beloved Master <3");
|
await e.Channel.SendMessage(e.User.Mention + " I don't need your permission to praise my beloved Master <3").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(u.Mention + NadekoBot.Locale.Praises[rng.Next(0, NadekoBot.Locale.Praises.Length)]);
|
await e.Channel.SendMessage(u.Mention + NadekoBot.Locale.Praises[rng.Next(0, NadekoBot.Locale.Praises.Length)]).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("pat")
|
cgb.CreateCommand("pat")
|
||||||
@ -239,11 +236,12 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
await e.Channel.SendMessage(
|
await e.Channel.SendMessage(
|
||||||
$"{user.Mention} " +
|
$"{user.Mention} " +
|
||||||
$"{NadekoBot.Config.PatResponses[rng.Next(0, NadekoBot.Config.PatResponses.Length)]}");
|
$"{NadekoBot.Config.PatResponses[rng.Next(0, NadekoBot.Config.PatResponses.Length)]}")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error while handling PatResponses check your data/config.json");
|
await e.Channel.SendMessage("Error while handling PatResponses check your data/config.json").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -255,11 +253,12 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
await
|
await
|
||||||
e.Channel.SendMessage(
|
e.Channel.SendMessage(
|
||||||
$"(•̥́ _•ૅ。)\n{NadekoBot.Config.CryResponses[rng.Next(0, NadekoBot.Config.CryResponses.Length)]}");
|
$"(•̥́ _•ૅ。)\n{NadekoBot.Config.CryResponses[rng.Next(0, NadekoBot.Config.CryResponses.Length)]}")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error while handling CryResponses check your data/config.json");
|
await e.Channel.SendMessage("Error while handling CryResponses check your data/config.json").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -271,11 +270,13 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
await
|
await
|
||||||
e.Channel.SendMessage(
|
e.Channel.SendMessage(
|
||||||
$"{NadekoBot.Config.DisguiseResponses[rng.Next(0, NadekoBot.Config.DisguiseResponses.Length)]}");
|
$"{NadekoBot.Config.DisguiseResponses[rng.Next(0, NadekoBot.Config.DisguiseResponses.Length)]}")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Error while handling DisguiseResponses check your data/config.json");
|
await e.Channel.SendMessage("Error while handling DisguiseResponses check your data/config.json")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -283,7 +284,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
.Description("Useless.")
|
.Description("Useless.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.User.Mention + " I will be soon.");
|
await e.Channel.SendMessage(e.User.Mention + " I will be soon.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("are you there")
|
cgb.CreateCommand("are you there")
|
||||||
@ -295,7 +296,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
.Description("Nadeko instructs you to type $draw. Gambling functions start with $")
|
.Description("Nadeko instructs you to type $draw. Gambling functions start with $")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Sorry, I don't gamble, type $draw for that function.");
|
await e.Channel.SendMessage("Sorry, I don't gamble, type $draw for that function.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand("fire")
|
cgb.CreateCommand("fire")
|
||||||
.Description("Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire.\n**Usage**: @NadekoBot fire [x]")
|
.Description("Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire.\n**Usage**: @NadekoBot fire [x]")
|
||||||
@ -308,7 +309,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
count = 1;
|
count = 1;
|
||||||
if (count < 1 || count > 12)
|
if (count < 1 || count > 12)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Number must be between 0 and 12");
|
await e.Channel.SendMessage("Number must be between 0 and 12").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +318,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
str += firestr;
|
str += firestr;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(str);
|
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("rip")
|
cgb.CreateCommand("rip")
|
||||||
@ -331,9 +332,11 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
|
var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
|
||||||
var text = "";
|
var text = "";
|
||||||
text = usr?.Name ?? e.GetArg("user");
|
text = usr?.Name ?? e.GetArg("user");
|
||||||
await
|
await e.Channel.SendFile("ripzor_m8.png",
|
||||||
e.Channel.SendFile("ripzor_m8.png",
|
RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year"))
|
||||||
RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year")) ? null : e.GetArg("year")));
|
? null
|
||||||
|
: e.GetArg("year")))
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
if (!NadekoBot.Config.DontJoinServers)
|
if (!NadekoBot.Config.DontJoinServers)
|
||||||
{
|
{
|
||||||
@ -342,21 +345,21 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
.Parameter("id", ParameterType.Required)
|
.Parameter("id", ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var invite = await client.GetInvite(e.Args[0]);
|
var invite = await client.GetInvite(e.Args[0]).ConfigureAwait(false);
|
||||||
if (invite != null)
|
if (invite != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await invite.Accept();
|
await invite.Accept().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Failed to accept invite.");
|
await e.Channel.SendMessage("Failed to accept invite.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("I got in!");
|
await e.Channel.SendMessage("I got in!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Invalid code.");
|
await e.Channel.SendMessage("Invalid code.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +369,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
|
|
||||||
Message msg = null;
|
Message msg = null;
|
||||||
var msgs = (await e.Channel.DownloadMessages(100))
|
var msgs = (await e.Channel.DownloadMessages(100).ConfigureAwait(false))
|
||||||
.Where(m => m.MentionedUsers.Contains(e.User))
|
.Where(m => m.MentionedUsers.Contains(e.User))
|
||||||
.OrderByDescending(m => m.Timestamp);
|
.OrderByDescending(m => m.Timestamp);
|
||||||
if (msgs.Any())
|
if (msgs.Any())
|
||||||
@ -377,7 +380,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
Message lastMessage = null;
|
Message lastMessage = null;
|
||||||
while (msg == null && attempt++ < 5)
|
while (msg == null && attempt++ < 5)
|
||||||
{
|
{
|
||||||
var msgsarr = await e.Channel.DownloadMessages(100, lastMessage?.Id);
|
var msgsarr = await e.Channel.DownloadMessages(100, lastMessage?.Id).ConfigureAwait(false);
|
||||||
msg = msgsarr
|
msg = msgsarr
|
||||||
.Where(m => m.MentionedUsers.Contains(e.User))
|
.Where(m => m.MentionedUsers.Contains(e.User))
|
||||||
.OrderByDescending(m => m.Timestamp)
|
.OrderByDescending(m => m.Timestamp)
|
||||||
@ -386,9 +389,10 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg != null)
|
if (msg != null)
|
||||||
await e.Channel.SendMessage($"Last message mentioning you was at {msg.Timestamp}\n**Message from {msg.User.Name}:** {msg.RawText}");
|
await e.Channel.SendMessage($"Last message mentioning you was at {msg.Timestamp}\n**Message from {msg.User.Name}:** {msg.RawText}")
|
||||||
|
.ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("I can't find a message mentioning you.");
|
await e.Channel.SendMessage("I can't find a message mentioning you.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("bb")
|
cgb.CreateCommand("bb")
|
||||||
@ -402,7 +406,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
if (u.Id != NadekoBot.Client.CurrentUser.Id)
|
if (u.Id != NadekoBot.Client.CurrentUser.Id)
|
||||||
str += " " + u.Mention;
|
str += " " + u.Mention;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(str);
|
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("call")
|
cgb.CreateCommand("call")
|
||||||
@ -410,7 +414,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
.Parameter("who", ParameterType.Required)
|
.Parameter("who", ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Calling " + e.Args[0] + "...");
|
await e.Channel.SendMessage("Calling " + e.Args[0] + "...").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand("hide")
|
cgb.CreateCommand("hide")
|
||||||
.Description("Hides Nadeko in plain sight!11!!")
|
.Description("Hides Nadeko in plain sight!11!!")
|
||||||
@ -418,9 +422,9 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
using (var ms = Resources.hidden.ToStream(ImageFormat.Png))
|
using (var ms = Resources.hidden.ToStream(ImageFormat.Png))
|
||||||
{
|
{
|
||||||
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: ms);
|
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: ms).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("*hides*");
|
await e.Channel.SendMessage("*hides*").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("unhide")
|
cgb.CreateCommand("unhide")
|
||||||
@ -429,9 +433,9 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
using (var fs = new FileStream("data/avatar.png", FileMode.Open))
|
using (var fs = new FileStream("data/avatar.png", FileMode.Open))
|
||||||
{
|
{
|
||||||
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: fs);
|
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: fs).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("*unhides*");
|
await e.Channel.SendMessage("*unhides*").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("dump")
|
cgb.CreateCommand("dump")
|
||||||
@ -446,7 +450,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var invite = await s.CreateInvite(0);
|
var invite = await s.CreateInvite(0).ConfigureAwait(false);
|
||||||
invites += invite.Url + "\n";
|
invites += invite.Url + "\n";
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -457,7 +461,8 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
File.WriteAllText("dump.txt", invites);
|
File.WriteAllText("dump.txt", invites);
|
||||||
await e.Channel.SendMessage($"Got invites for {i} servers and failed to get invites for {j} servers");
|
await e.Channel.SendMessage($"Got invites for {i} servers and failed to get invites for {j} servers")
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("ab")
|
cgb.CreateCommand("ab")
|
||||||
@ -471,7 +476,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
construct += strings[rng.Next(0, strings.Length)];
|
construct += strings[rng.Next(0, strings.Length)];
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(construct);
|
await e.Channel.SendMessage(construct).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("av").Alias("avatar")
|
cgb.CreateCommand("av").Alias("avatar")
|
||||||
@ -482,10 +487,10 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
|
var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Invalid user specified.");
|
await e.Channel.SendMessage("Invalid user specified.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(await usr.AvatarUrl.ShortenUrl());
|
await e.Channel.SendMessage(await usr.AvatarUrl.ShortenUrl()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -515,6 +520,6 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Func<CommandEventArgs, Task> SayYes()
|
private static Func<CommandEventArgs, Task> SayYes()
|
||||||
=> async e => await e.Channel.SendMessage("Yes. :)");
|
=> async e => await e.Channel.SendMessage("Yes. :)").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
var imageStream = new Image[2] { GetDice(num1), GetDice(num2) }.Merge().ToStream(ImageFormat.Png);
|
var imageStream = new Image[2] { GetDice(num1), GetDice(num2) }.Merge().ToStream(ImageFormat.Png);
|
||||||
|
|
||||||
await e.Channel.SendFile("dice.png", imageStream);
|
await e.Channel.SendFile("dice.png", imageStream).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Match m;
|
Match m;
|
||||||
@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
arr[i] = r.Next(1, n2 + 1);
|
arr[i] = r.Next(1, n2 + 1);
|
||||||
}
|
}
|
||||||
var elemCnt = 0;
|
var elemCnt = 0;
|
||||||
await e.Channel.SendMessage($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", arr.OrderBy(x => x).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString())));
|
await e.Channel.SendMessage($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", arr.OrderBy(x => x).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
if (num < 1) num = 1;
|
if (num < 1) num = 1;
|
||||||
if (num > 30)
|
if (num > 30)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You can roll up to 30 dice at a time.");
|
await e.Channel.SendMessage("You can roll up to 30 dice at a time.").ConfigureAwait(false);
|
||||||
num = 30;
|
num = 30;
|
||||||
}
|
}
|
||||||
var dices = new List<Image>(num);
|
var dices = new List<Image>(num);
|
||||||
@ -108,12 +108,12 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
|
|
||||||
var bitmap = dices.Merge();
|
var bitmap = dices.Merge();
|
||||||
await e.Channel.SendMessage(values.Count + " Dice rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**");
|
await e.Channel.SendMessage(values.Count + " Dice rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**").ConfigureAwait(false);
|
||||||
await e.Channel.SendFile("dice.png", bitmap.ToStream(ImageFormat.Png));
|
await e.Channel.SendFile("dice.png", bitmap.ToStream(ImageFormat.Png)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Please enter a number of dice to roll.");
|
await e.Channel.SendMessage("Please enter a number of dice to roll.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -140,11 +140,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
rolled = new Random().Next(0, int.Parse(e.GetArg("range")) + 1);
|
rolled = new Random().Next(0, int.Parse(e.GetArg("range")) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} rolled **{rolled}**.");
|
await e.Channel.SendMessage($"{e.User.Mention} rolled **{rolled}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($":anger: {ex.Message}");
|
await e.Channel.SendMessage($":anger: {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
return c;
|
return c;
|
||||||
});
|
});
|
||||||
|
|
||||||
await e.Channel.SendMessage("Deck reshuffled.");
|
await e.Channel.SendMessage("Deck reshuffled.").ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
if (!isParsed || num < 2)
|
if (!isParsed || num < 2)
|
||||||
{
|
{
|
||||||
var c = cards.DrawACard();
|
var c = cards.DrawACard();
|
||||||
await e.Channel.SendFile(c.Name + ".jpg", (Properties.Resources.ResourceManager.GetObject(c.Name) as Image).ToStream());
|
await e.Channel.SendFile(c.Name + ".jpg", (Properties.Resources.ResourceManager.GetObject(c.Name) as Image).ToStream()).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (num > 5)
|
if (num > 5)
|
||||||
@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
if (cards.CardPool.Count == 0 && i != 0)
|
if (cards.CardPool.Count == 0 && i != 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("No more cards in a deck.");
|
await e.Channel.SendMessage("No more cards in a deck.").ConfigureAwait(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var currentCard = cards.DrawACard();
|
var currentCard = cards.DrawACard();
|
||||||
@ -76,10 +76,10 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image);
|
images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image);
|
||||||
}
|
}
|
||||||
var bitmap = images.Merge();
|
var bitmap = images.Merge();
|
||||||
await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream());
|
await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()).ConfigureAwait(false);
|
||||||
if (cardObjects.Count == 5)
|
if (cardObjects.Count == 5)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(Cards.GetHandValue(cardObjects));
|
await e.Channel.SendMessage(Cards.GetHandValue(cardObjects)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -30,11 +30,12 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
if (e.GetArg("count") == "")
|
if (e.GetArg("count") == "")
|
||||||
{
|
{
|
||||||
if (rng.Next(0, 2) == 1)
|
if (rng.Next(0, 2) == 1)
|
||||||
await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png));
|
await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendFile("tails.png", Properties.Resources.tails.ToStream(System.Drawing.Imaging.ImageFormat.Png));
|
await e.Channel.SendFile("tails.png", Properties.Resources.tails.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
int result;
|
int result;
|
||||||
if (int.TryParse(e.GetArg("count"), out result))
|
if (int.TryParse(e.GetArg("count"), out result))
|
||||||
{
|
{
|
||||||
@ -47,10 +48,10 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
Properties.Resources.tails :
|
Properties.Resources.tails :
|
||||||
Properties.Resources.heads;
|
Properties.Resources.heads;
|
||||||
}
|
}
|
||||||
await e.Channel.SendFile($"{result} coins.png", imgs.Merge().ToStream(System.Drawing.Imaging.ImageFormat.Png));
|
await e.Channel.SendFile($"{result} coins.png", imgs.Merge().ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("Invalid number");
|
await e.Channel.SendMessage("Invalid number").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -60,14 +60,14 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
if (userFlowers < amount)
|
if (userFlowers < amount)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You have only {userFlowers}{NadekoBot.Config.CurrencySign}.");
|
await e.Channel.SendMessage($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You have only {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlowersHandler.RemoveFlowers(e.User, "Gift", (int)amount);
|
FlowersHandler.RemoveFlowers(e.User, "Gift", (int)amount);
|
||||||
await FlowersHandler.AddFlowersAsync(mentionedUser, "Gift", (int)amount);
|
await FlowersHandler.AddFlowersAsync(mentionedUser, "Gift", (int)amount).ConfigureAwait(false);
|
||||||
|
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} successfully sent {amount} {NadekoBot.Config.CurrencyName}s to {mentionedUser.Mention}!");
|
await e.Channel.SendMessage($"{e.User.Mention} successfully sent {amount} {NadekoBot.Config.CurrencyName}s to {mentionedUser.Mention}!").ConfigureAwait(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -88,9 +88,9 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
if (mentionedUser == null)
|
if (mentionedUser == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await FlowersHandler.AddFlowersAsync(mentionedUser, $"Awarded by bot owner. ({e.User.Name}/{e.User.Id})", (int)amount);
|
await FlowersHandler.AddFlowersAsync(mentionedUser, $"Awarded by bot owner. ({e.User.Name}/{e.User.Id})", (int)amount).ConfigureAwait(false);
|
||||||
|
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} successfully awarded {amount} {NadekoBot.Config.CurrencyName}s to {mentionedUser.Mention}!");
|
await e.Channel.SendMessage($"{e.User.Mention} successfully awarded {amount} {NadekoBot.Config.CurrencyName}s to {mentionedUser.Mention}!").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "take")
|
cgb.CreateCommand(Prefix + "take")
|
||||||
@ -112,7 +112,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
FlowersHandler.RemoveFlowers(mentionedUser, $"Taken by bot owner.({e.User.Name}/{e.User.Id})", (int)amount);
|
FlowersHandler.RemoveFlowers(mentionedUser, $"Taken by bot owner.({e.User.Name}/{e.User.Id})", (int)amount);
|
||||||
|
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from {mentionedUser.Mention}!");
|
await e.Channel.SendMessage($"{e.User.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from {mentionedUser.Mention}!").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
str += NadekoBot.Config.CurrencySign;
|
str += NadekoBot.Config.CurrencySign;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(str);
|
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,13 +142,13 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
var role = e.Server.FindRoles(arg).FirstOrDefault();
|
var role = e.Server.FindRoles(arg).FirstOrDefault();
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Role not found.");
|
await e.Channel.SendMessage("💢 Role not found.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var members = role.Members.Where(u => u.Status == UserStatus.Online); // only online
|
var members = role.Members.Where(u => u.Status == UserStatus.Online); // only online
|
||||||
var membersArray = members as User[] ?? members.ToArray();
|
var membersArray = members as User[] ?? members.ToArray();
|
||||||
var usr = membersArray[new Random().Next(0, membersArray.Length)];
|
var usr = membersArray[new Random().Next(0, membersArray.Length)];
|
||||||
await e.Channel.SendMessage($"**Raffled user:** {usr.Name} (id: {usr.Id})");
|
await e.Channel.SendMessage($"**Raffled user:** {usr.Name} (id: {usr.Id})").ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
"If Nadeko betrays - you both lose some points.")
|
"If Nadeko betrays - you both lose some points.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await ReceiveAnswer(e, Answers.Betray);
|
await ReceiveAnswer(e, Answers.Betray).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "cooperate")
|
cgb.CreateCommand(Module.Prefix + "cooperate")
|
||||||
@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
|
|
||||||
await ReceiveAnswer(e, Answers.Cooperate);
|
await ReceiveAnswer(e, Answers.Cooperate).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,14 +96,15 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
$"--------------------------------\n" +
|
$"--------------------------------\n" +
|
||||||
$"Nadeko has {NadekoPoints} points." +
|
$"Nadeko has {NadekoPoints} points." +
|
||||||
$"You have {UserPoints} points." +
|
$"You have {UserPoints} points." +
|
||||||
$"--------------------------------\n");
|
$"--------------------------------\n")
|
||||||
|
.ConfigureAwait(false);
|
||||||
if (round < 10) return;
|
if (round < 10) return;
|
||||||
if (nadekoPoints == userPoints)
|
if (nadekoPoints == userPoints)
|
||||||
await e.Channel.SendMessage("Its a draw");
|
await e.Channel.SendMessage("Its a draw").ConfigureAwait(false);
|
||||||
else if (nadekoPoints > userPoints)
|
else if (nadekoPoints > userPoints)
|
||||||
await e.Channel.SendMessage("Nadeko won.");
|
await e.Channel.SendMessage("Nadeko won.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("You won.");
|
await e.Channel.SendMessage("You won.").ConfigureAwait(false);
|
||||||
nadekoPoints = 0;
|
nadekoPoints = 0;
|
||||||
userPoints = 0;
|
userPoints = 0;
|
||||||
round = 0;
|
round = 0;
|
||||||
|
@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
boardStr.AppendLine();
|
boardStr.AppendLine();
|
||||||
}
|
}
|
||||||
if (godMsg.Id != 0)
|
if (godMsg.Id != 0)
|
||||||
await godMsg.Edit(boardStr.ToString());
|
await godMsg.Edit(boardStr.ToString()).ConfigureAwait(false);
|
||||||
|
|
||||||
};
|
};
|
||||||
t.Interval = 1000;
|
t.Interval = 1000;
|
||||||
@ -93,7 +93,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
// {
|
// {
|
||||||
// if (gameChannel != null)
|
// if (gameChannel != null)
|
||||||
// return;
|
// return;
|
||||||
// godMsg = await e.Channel.SendMessage("GAME START IN 1 SECOND....");
|
// godMsg = await e.Channel.SendMessage("GAME START IN 1 SECOND....").ConfigureAwait(false);
|
||||||
// gameChannel = e.Channel;
|
// gameChannel = e.Channel;
|
||||||
// players[0] = new BombermanPlayer
|
// players[0] = new BombermanPlayer
|
||||||
// {
|
// {
|
||||||
|
@ -309,7 +309,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
return;
|
return;
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage(ToLeet(text, level));
|
await e.Channel.SendMessage(ToLeet(text, level)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,15 +36,15 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
{
|
{
|
||||||
Message msg;
|
Message msg;
|
||||||
|
|
||||||
await e.Message.Delete();
|
await e.Message.Delete().ConfigureAwait(false);
|
||||||
if (!plantedFlowerChannels.TryRemove(e.Channel.Id, out msg))
|
if (!plantedFlowerChannels.TryRemove(e.Channel.Id, out msg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await msg.Delete();
|
await msg.Delete().ConfigureAwait(false);
|
||||||
await FlowersHandler.AddFlowersAsync(e.User, "Picked a flower.", 1, true);
|
await FlowersHandler.AddFlowersAsync(e.User, "Picked a flower.", 1, true).ConfigureAwait(false);
|
||||||
msg = await e.Channel.SendMessage($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!");
|
msg = await e.Channel.SendMessage($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!").ConfigureAwait(false);
|
||||||
await Task.Delay(10000);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
await msg.Delete();
|
await msg.Delete().ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "plant")
|
cgb.CreateCommand(Module.Prefix + "plant")
|
||||||
@ -68,6 +68,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
var rng = new Random();
|
var rng = new Random();
|
||||||
var file = Directory.GetFiles("data/currency_images").OrderBy(s => rng.Next()).FirstOrDefault();
|
var file = Directory.GetFiles("data/currency_images").OrderBy(s => rng.Next()).FirstOrDefault();
|
||||||
Message msg;
|
Message msg;
|
||||||
|
//todo send message after, not in lock
|
||||||
if (file == null)
|
if (file == null)
|
||||||
msg = e.Channel.SendMessage(NadekoBot.Config.CurrencySign).GetAwaiter().GetResult();
|
msg = e.Channel.SendMessage(NadekoBot.Config.CurrencySign).GetAwaiter().GetResult();
|
||||||
else
|
else
|
||||||
@ -76,8 +77,8 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
}
|
}
|
||||||
var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]);
|
var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]);
|
||||||
var msg2 = await e.Channel.SendMessage($"Oh how Nice! **{e.User.Name}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick");
|
var msg2 = await e.Channel.SendMessage($"Oh how Nice! **{e.User.Name}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick");
|
||||||
await Task.Delay(20000);
|
await Task.Delay(20000).ConfigureAwait(false);
|
||||||
await msg2.Delete();
|
await msg2.Delete().ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,9 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
var poll = new Poll(e, data[0], data.Skip(1));
|
var poll = new Poll(e, data[0], data.Skip(1));
|
||||||
if (PollCommand.ActivePolls.TryAdd(e.Server, poll))
|
if (PollCommand.ActivePolls.TryAdd(e.Server, poll))
|
||||||
{
|
{
|
||||||
await poll.StartPoll();
|
await poll.StartPoll().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Module.Prefix + "pollend")
|
cgb.CreateCommand(Module.Prefix + "pollend")
|
||||||
.Description("Stops active poll on this server and prints the results in this channel.")
|
.Description("Stops active poll on this server and prints the results in this channel.")
|
||||||
@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
return;
|
return;
|
||||||
if (!ActivePolls.ContainsKey(e.Server))
|
if (!ActivePolls.ContainsKey(e.Server))
|
||||||
return;
|
return;
|
||||||
await ActivePolls[e.Server].StopPoll(e.Channel);
|
await ActivePolls[e.Server].StopPoll(e.Channel).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
var num = 1;
|
var num = 1;
|
||||||
msgToSend = answers.Aggregate(msgToSend, (current, answ) => current + $"`{num++}.` **{answ}**\n");
|
msgToSend = answers.Aggregate(msgToSend, (current, answ) => current + $"`{num++}.` **{answ}**\n");
|
||||||
msgToSend += "\n**Private Message me with the corresponding number of the answer.**";
|
msgToSend += "\n**Private Message me with the corresponding number of the answer.**";
|
||||||
await e.Channel.SendMessage(msgToSend);
|
await e.Channel.SendMessage(msgToSend).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StopPoll(Channel ch)
|
public async Task StopPoll(Channel ch)
|
||||||
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
var totalVotesCast = results.Sum(kvp => kvp.Value);
|
var totalVotesCast = results.Sum(kvp => kvp.Value);
|
||||||
if (totalVotesCast == 0)
|
if (totalVotesCast == 0)
|
||||||
{
|
{
|
||||||
await ch.SendMessage("📄 **No votes have been cast.**");
|
await ch.SendMessage("📄 **No votes have been cast.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var closeMessage = $"--------------**POLL CLOSED**--------------\n" +
|
var closeMessage = $"--------------**POLL CLOSED**--------------\n" +
|
||||||
@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
$" has {kvp.Value} votes." +
|
$" has {kvp.Value} votes." +
|
||||||
$"({kvp.Value * 1.0f / totalVotesCast * 100}%)\n");
|
$"({kvp.Value * 1.0f / totalVotesCast * 100}%)\n");
|
||||||
|
|
||||||
await ch.SendMessage($"📄 **Total votes cast**: {totalVotesCast}\n{closeMessage}");
|
await ch.SendMessage($"📄 **Total votes cast**: {totalVotesCast}\n{closeMessage}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
return;
|
return;
|
||||||
if (participants.TryAdd(e.User, vote))
|
if (participants.TryAdd(e.User, vote))
|
||||||
{
|
{
|
||||||
await e.User.SendMessage($"Thanks for voting **{e.User.Name}**.");
|
await e.User.SendMessage($"Thanks for voting **{e.User.Name}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
@ -56,7 +56,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
IsActive = false;
|
IsActive = false;
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
sw.Reset();
|
sw.Reset();
|
||||||
await channel.Send("Typing contest stopped");
|
await channel.Send("Typing contest stopped").ConfigureAwait(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,28 +68,28 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
IsActive = true;
|
IsActive = true;
|
||||||
CurrentSentence = SentencesProvider.GetRandomSentence();
|
CurrentSentence = SentencesProvider.GetRandomSentence();
|
||||||
var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f);
|
var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f);
|
||||||
await channel.SendMessage($":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.");
|
await channel.SendMessage($":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
||||||
var msg = await channel.SendMessage("Starting new typing contest in **3**...");
|
var msg = await channel.SendMessage("Starting new typing contest in **3**...").ConfigureAwait(false);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
await msg.Edit("Starting new typing contest in **2**...");
|
await msg.Edit("Starting new typing contest in **2**...").ConfigureAwait(false);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
await msg.Edit("Starting new typing contest in **1**...");
|
await msg.Edit("Starting new typing contest in **1**...").ConfigureAwait(false);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
await msg.Edit($":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:");
|
await msg.Edit($":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:").ConfigureAwait(false);
|
||||||
sw.Start();
|
sw.Start();
|
||||||
HandleAnswers();
|
HandleAnswers();
|
||||||
|
|
||||||
while (i > 0)
|
while (i > 0)
|
||||||
{
|
{
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
i--;
|
i--;
|
||||||
if (!IsActive)
|
if (!IsActive)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Stop();
|
await Stop().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,10 +111,10 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
if (decision && !finishedUserIds.Contains(e.User.Id))
|
if (decision && !finishedUserIds.Contains(e.User.Id))
|
||||||
{
|
{
|
||||||
finishedUserIds.Add(e.User.Id);
|
finishedUserIds.Add(e.User.Id);
|
||||||
await channel.Send($"{e.User.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!");
|
await channel.Send($"{e.User.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false);
|
||||||
if (finishedUserIds.Count % 2 == 0)
|
if (finishedUserIds.Count % 2 == 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:");
|
await e.Channel.SendMessage($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,11 +144,12 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
{
|
{
|
||||||
await e.Channel.SendMessage(
|
await e.Channel.SendMessage(
|
||||||
$"Contest already running in " +
|
$"Contest already running in " +
|
||||||
$"{game.Channell.Mention} channel.");
|
$"{game.Channell.Mention} channel.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await game.Start();
|
await game.Start().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -158,10 +159,10 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
TypingGame game;
|
TypingGame game;
|
||||||
if (RunningContests.TryRemove(e.User.Server.Id, out game))
|
if (RunningContests.TryRemove(e.User.Server.Id, out game))
|
||||||
{
|
{
|
||||||
await game.Stop();
|
await game.Stop().ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("No contest to stop on this channel.");
|
await e.Channel.SendMessage("No contest to stop on this channel.").ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
internal override void Init(CommandGroupBuilder cgb)
|
||||||
@ -187,7 +188,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
DateAdded = DateTime.Now
|
DateAdded = DateTime.Now
|
||||||
});
|
});
|
||||||
|
|
||||||
await e.Channel.SendMessage("Added new article for typing game.");
|
await e.Channel.SendMessage("Added new article for typing game.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
//todo add user submissions
|
//todo add user submissions
|
||||||
|
@ -53,13 +53,13 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
|||||||
CurrentQuestion = TriviaQuestionPool.Instance.GetRandomQuestion(oldQuestions);
|
CurrentQuestion = TriviaQuestionPool.Instance.GetRandomQuestion(oldQuestions);
|
||||||
if (CurrentQuestion == null)
|
if (CurrentQuestion == null)
|
||||||
{
|
{
|
||||||
await channel.SendMessage($":exclamation: Failed loading a trivia question");
|
await channel.SendMessage($":exclamation: Failed loading a trivia question").ConfigureAwait(false);
|
||||||
await End();
|
await End().ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
oldQuestions.Add(CurrentQuestion); //add it to exclusion list so it doesn't show up again
|
oldQuestions.Add(CurrentQuestion); //add it to exclusion list so it doesn't show up again
|
||||||
//sendquestion
|
//sendquestion
|
||||||
await channel.SendMessage($":question: **{CurrentQuestion.Question}**");
|
await channel.SendMessage($":question: **{CurrentQuestion.Question}**").ConfigureAwait(false);
|
||||||
|
|
||||||
//receive messages
|
//receive messages
|
||||||
NadekoBot.Client.MessageReceived += PotentialGuess;
|
NadekoBot.Client.MessageReceived += PotentialGuess;
|
||||||
@ -70,12 +70,12 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//hint
|
//hint
|
||||||
await Task.Delay(HintTimeoutMiliseconds, token);
|
await Task.Delay(HintTimeoutMiliseconds, token).ConfigureAwait(false);
|
||||||
if (ShowHints)
|
if (ShowHints)
|
||||||
await channel.SendMessage($":exclamation:**Hint:** {CurrentQuestion.GetHint()}");
|
await channel.SendMessage($":exclamation:**Hint:** {CurrentQuestion.GetHint()}").ConfigureAwait(false);
|
||||||
|
|
||||||
//timeout
|
//timeout
|
||||||
await Task.Delay(QuestionDurationMiliseconds - HintTimeoutMiliseconds, token);
|
await Task.Delay(QuestionDurationMiliseconds - HintTimeoutMiliseconds, token).ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException)
|
catch (TaskCanceledException)
|
||||||
@ -84,18 +84,18 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
|||||||
}
|
}
|
||||||
GameActive = false;
|
GameActive = false;
|
||||||
if (!triviaCancelSource.IsCancellationRequested)
|
if (!triviaCancelSource.IsCancellationRequested)
|
||||||
await channel.Send($":clock2: :question: **Time's up!** The correct answer was **{CurrentQuestion.Answer}**");
|
await channel.Send($":clock2: :question: **Time's up!** The correct answer was **{CurrentQuestion.Answer}**").ConfigureAwait(false);
|
||||||
NadekoBot.Client.MessageReceived -= PotentialGuess;
|
NadekoBot.Client.MessageReceived -= PotentialGuess;
|
||||||
// load next question if game is still running
|
// load next question if game is still running
|
||||||
await Task.Delay(2000);
|
await Task.Delay(2000).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await End();
|
await End().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task End()
|
private async Task End()
|
||||||
{
|
{
|
||||||
ShouldStopGame = true;
|
ShouldStopGame = true;
|
||||||
await channel.SendMessage("**Trivia game ended**\n" + GetLeaderboard());
|
await channel.SendMessage("**Trivia game ended**\n" + GetLeaderboard()).ConfigureAwait(false);
|
||||||
TriviaGame throwAwayValue;
|
TriviaGame throwAwayValue;
|
||||||
TriviaCommands.RunningTrivias.TryRemove(server.Id, out throwAwayValue);
|
TriviaCommands.RunningTrivias.TryRemove(server.Id, out throwAwayValue);
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
|||||||
public async Task StopGame()
|
public async Task StopGame()
|
||||||
{
|
{
|
||||||
if (!ShouldStopGame)
|
if (!ShouldStopGame)
|
||||||
await channel.SendMessage(":exclamation: Trivia will stop after this question.");
|
await channel.SendMessage(":exclamation: Trivia will stop after this question.").ConfigureAwait(false);
|
||||||
ShouldStopGame = true;
|
ShouldStopGame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,12 +127,12 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
|||||||
}
|
}
|
||||||
if (!guess) return;
|
if (!guess) return;
|
||||||
triviaCancelSource.Cancel();
|
triviaCancelSource.Cancel();
|
||||||
await channel.SendMessage($"☑️ {e.User.Mention} guessed it! The answer was: **{CurrentQuestion.Answer}**");
|
await channel.SendMessage($"☑️ {e.User.Mention} guessed it! The answer was: **{CurrentQuestion.Answer}**").ConfigureAwait(false);
|
||||||
if (Users[e.User] != WinRequirement) return;
|
if (Users[e.User] != WinRequirement) return;
|
||||||
ShouldStopGame = true;
|
ShouldStopGame = true;
|
||||||
await channel.Send($":exclamation: We have a winner! Its {e.User.Mention}.");
|
await channel.Send($":exclamation: We have a winner! Its {e.User.Mention}.").ConfigureAwait(false);
|
||||||
// add points to the winner
|
// add points to the winner
|
||||||
await FlowersHandler.AddFlowersAsync(e.User, "Won Trivia", 2);
|
await FlowersHandler.AddFlowersAsync(e.User, "Won Trivia", 2).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
var showHints = !e.Args.Contains("nohint");
|
var showHints = !e.Args.Contains("nohint");
|
||||||
var triviaGame = new TriviaGame(e, showHints);
|
var triviaGame = new TriviaGame(e, showHints);
|
||||||
if (RunningTrivias.TryAdd(e.Server.Id, triviaGame))
|
if (RunningTrivias.TryAdd(e.Server.Id, triviaGame))
|
||||||
await e.Channel.SendMessage("**Trivia game started!**");
|
await e.Channel.SendMessage("**Trivia game started!**").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await triviaGame.StopGame();
|
await triviaGame.StopGame().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("Trivia game is already running on this server.\n" + trivia.CurrentQuestion);
|
await e.Channel.SendMessage("Trivia game is already running on this server.\n" + trivia.CurrentQuestion).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "tl")
|
cgb.CreateCommand(Module.Prefix + "tl")
|
||||||
@ -43,9 +43,9 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
{
|
{
|
||||||
TriviaGame trivia;
|
TriviaGame trivia;
|
||||||
if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
|
if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
|
||||||
await e.Channel.SendMessage(trivia.GetLeaderboard());
|
await e.Channel.SendMessage(trivia.GetLeaderboard()).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("No trivia is running on this server.");
|
await e.Channel.SendMessage("No trivia is running on this server.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "tq")
|
cgb.CreateCommand(Module.Prefix + "tq")
|
||||||
@ -55,10 +55,10 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
TriviaGame trivia;
|
TriviaGame trivia;
|
||||||
if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
|
if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
|
||||||
{
|
{
|
||||||
await trivia.StopGame();
|
await trivia.StopGame().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("No trivia is running on this server.");
|
await e.Channel.SendMessage("No trivia is running on this server.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
var list = arg.Split(';');
|
var list = arg.Split(';');
|
||||||
if (list.Count() < 2)
|
if (list.Count() < 2)
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage(list[rng.Next(0, list.Length)]);
|
await e.Channel.SendMessage(list[rng.Next(0, list.Length)]).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "8ball")
|
cgb.CreateCommand(Prefix + "8ball")
|
||||||
@ -60,7 +60,8 @@ namespace NadekoBot.Modules.Games
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(
|
await e.Channel.SendMessage(
|
||||||
$":question: **Question**: `{question}` \n🎱 **8Ball Answers**: `{NadekoBot.Config._8BallResponses[rng.Next(0, NadekoBot.Config._8BallResponses.Length)]}`");
|
$":question: **Question**: `{question}` \n🎱 **8Ball Answers**: `{NadekoBot.Config._8BallResponses[rng.Next(0, NadekoBot.Config._8BallResponses.Length)]}`")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
});
|
});
|
||||||
@ -102,7 +103,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
else
|
else
|
||||||
msg = $"{e.User.Mention} won! :{GetRPSPick(pick)}: beats :{GetRPSPick(nadekoPick)}:";
|
msg = $"{e.User.Mention} won! :{GetRPSPick(pick)}: beats :{GetRPSPick(nadekoPick)}:";
|
||||||
|
|
||||||
await e.Channel.SendMessage(msg);
|
await e.Channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "linux")
|
cgb.CreateCommand(Prefix + "linux")
|
||||||
@ -121,7 +122,7 @@ I'd just like to interject for moment. What you're refering to as {loonix}, is i
|
|||||||
Many computer users run a modified version of the {guhnoo} system every day, without realizing it. Through a peculiar turn of events, the version of {guhnoo} which is widely used today is often called {loonix}, and many of its users are not aware that it is basically the {guhnoo} system, developed by the {guhnoo} Project.
|
Many computer users run a modified version of the {guhnoo} system every day, without realizing it. Through a peculiar turn of events, the version of {guhnoo} which is widely used today is often called {loonix}, and many of its users are not aware that it is basically the {guhnoo} system, developed by the {guhnoo} Project.
|
||||||
|
|
||||||
There really is a {loonix}, and these people are using it, but it is just a part of the system they use. {loonix} is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. {loonix} is normally used in combination with the {guhnoo} operating system: the whole system is basically {guhnoo} with {loonix} added, or {guhnoo}/{loonix}. All the so-called {loonix} distributions are really distributions of {guhnoo}/{loonix}.
|
There really is a {loonix}, and these people are using it, but it is just a part of the system they use. {loonix} is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. {loonix} is normally used in combination with the {guhnoo} operating system: the whole system is basically {guhnoo} with {loonix} added, or {guhnoo}/{loonix}. All the so-called {loonix} distributions are really distributions of {guhnoo}/{loonix}.
|
||||||
");
|
").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -32,16 +32,16 @@ namespace NadekoBot.Classes.Help.Commands
|
|||||||
while (helpstr.Length > 2000)
|
while (helpstr.Length > 2000)
|
||||||
{
|
{
|
||||||
var curstr = helpstr.Substring(0, 2000);
|
var curstr = helpstr.Substring(0, 2000);
|
||||||
await e.User.Send(curstr.Substring(0, curstr.LastIndexOf("\n") + 1));
|
await e.User.Send(curstr.Substring(0, curstr.LastIndexOf("\n") + 1)).ConfigureAwait(false);
|
||||||
helpstr = curstr.Substring(curstr.LastIndexOf("\n") + 1) + helpstr.Substring(2000);
|
helpstr = curstr.Substring(curstr.LastIndexOf("\n") + 1) + helpstr.Substring(2000);
|
||||||
await Task.Delay(200);
|
await Task.Delay(200).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
#endregion OldHelp
|
#endregion OldHelp
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("command")))
|
if (string.IsNullOrWhiteSpace(e.GetArg("command")))
|
||||||
{
|
{
|
||||||
await e.User.Send(HelpString);
|
await e.User.Send(HelpString).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
@ -51,8 +51,8 @@ namespace NadekoBot.Classes.Help.Commands
|
|||||||
var com = NadekoBot.Client.GetService<CommandService>().AllCommands
|
var com = NadekoBot.Client.GetService<CommandService>().AllCommands
|
||||||
.FirstOrDefault(c => c.Text.ToLower().Equals(comToFind));
|
.FirstOrDefault(c => c.Text.ToLower().Equals(comToFind));
|
||||||
if (com != null)
|
if (com != null)
|
||||||
await e.Channel.SendMessage($"`Help for '{com.Text}':` **{com.Description}**");
|
await e.Channel.SendMessage($"`Help for '{com.Text}':` **{com.Description}**").ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
public static string HelpString => (NadekoBot.IsBot
|
public static string HelpString => (NadekoBot.IsBot
|
||||||
? $"To add me to your server, use this link** -> <https://discordapp.com/oauth2/authorize?client_id=170254782546575360&scope=bot&permissions=66186303>\n"
|
? $"To add me to your server, use this link** -> <https://discordapp.com/oauth2/authorize?client_id=170254782546575360&scope=bot&permissions=66186303>\n"
|
||||||
@ -116,7 +116,7 @@ Version: `{NadekoStats.Instance.BotVersion}`";
|
|||||||
|
|
||||||
**GUIDE ONLY**: <https://github.com/Kwoth/NadekoBot/blob/master/ComprehensiveGuide.md>
|
**GUIDE ONLY**: <https://github.com/Kwoth/NadekoBot/blob/master/ComprehensiveGuide.md>
|
||||||
|
|
||||||
**LIST OF COMMANDS**: <https://github.com/Kwoth/NadekoBot/blob/master/commandlist.md>"));
|
**LIST OF COMMANDS**: <https://github.com/Kwoth/NadekoBot/blob/master/commandlist.md>").ConfigureAwait(false));
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "donate")
|
cgb.CreateCommand(Module.Prefix + "donate")
|
||||||
.Alias("~donate")
|
.Alias("~donate")
|
||||||
@ -129,7 +129,7 @@ Don't forget to leave your discord name or id in the message, so that I can rewa
|
|||||||
You can join nadekobot server by typing {Module.Prefix}h and you will get an invite in a private message.
|
You can join nadekobot server by typing {Module.Prefix}h and you will get an invite in a private message.
|
||||||
|
|
||||||
*If you want to support in some other way or on a different platform, please message me*"
|
*If you want to support in some other way or on a different platform, please message me*"
|
||||||
);
|
).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ namespace NadekoBot.Modules.Help
|
|||||||
.Description("List all bot modules.")
|
.Description("List all bot modules.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("`List of modules:` \n• " + string.Join("\n• ", NadekoBot.Client.GetService<ModuleService>().Modules.Select(m => m.Name)));
|
await e.Channel.SendMessage("`List of modules:` \n• " + string.Join("\n• ", NadekoBot.Client.GetService<ModuleService>().Modules.Select(m => m.Name)))
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "commands")
|
cgb.CreateCommand(Prefix + "commands")
|
||||||
@ -43,10 +44,11 @@ namespace NadekoBot.Modules.Help
|
|||||||
var cmdsArray = cmds as Command[] ?? cmds.ToArray();
|
var cmdsArray = cmds as Command[] ?? cmds.ToArray();
|
||||||
if (!cmdsArray.Any())
|
if (!cmdsArray.Any())
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("That module does not exist.");
|
await e.Channel.SendMessage("That module does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", cmdsArray.Select(c => c.Text)));
|
await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", cmdsArray.Select(c => c.Text)))
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,11 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (audioClient?.State != ConnectionState.Connected)
|
if (audioClient?.State != ConnectionState.Connected)
|
||||||
audioClient = await PlaybackVoiceChannel.JoinAudio();
|
audioClient = await PlaybackVoiceChannel.JoinAudio().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CurrentSong = GetNextSong();
|
CurrentSong = GetNextSong();
|
||||||
@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
OnStarted(this, curSong);
|
OnStarted(this, curSong);
|
||||||
await curSong.Play(audioClient, cancelToken);
|
await curSong.Play(audioClient, cancelToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
SongCancelSource = new CancellationTokenSource();
|
SongCancelSource = new CancellationTokenSource();
|
||||||
cancelToken = SongCancelSource.Token;
|
cancelToken = SongCancelSource.Token;
|
||||||
}
|
}
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -175,10 +175,12 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSong(Song s, int index) {
|
public void AddSong(Song s, int index)
|
||||||
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
throw new ArgumentNullException(nameof(s));
|
throw new ArgumentNullException(nameof(s));
|
||||||
lock (playlistLock) {
|
lock (playlistLock)
|
||||||
|
{
|
||||||
playlist.Insert(index, s);
|
playlist.Insert(index, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
while (ContentLength + count > BufferSize)
|
while (ContentLength + count > BufferSize)
|
||||||
{
|
{
|
||||||
await Task.Delay(20, cancelToken);
|
await Task.Delay(20, cancelToken).ConfigureAwait(false);
|
||||||
if (cancelToken.IsCancellationRequested)
|
if (cancelToken.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,8 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
var read = 0;
|
var read = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
read = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, blockSize, cancelToken);
|
read = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, blockSize, cancelToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -100,10 +101,10 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
if (attempt++ == 50)
|
if (attempt++ == 50)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
await Task.Delay(100, cancelToken);
|
await Task.Delay(100, cancelToken).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
attempt = 0;
|
attempt = 0;
|
||||||
await songBuffer.WriteAsync(buffer, read, cancelToken);
|
await songBuffer.WriteAsync(buffer, read, cancelToken).ConfigureAwait(false);
|
||||||
if (songBuffer.ContentLength > 2.MB())
|
if (songBuffer.ContentLength > 2.MB())
|
||||||
prebufferingComplete = true;
|
prebufferingComplete = true;
|
||||||
}
|
}
|
||||||
@ -135,7 +136,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
var toAttemptTimes = SongInfo.ProviderType != MusicType.Normal ? 5 : 9;
|
var toAttemptTimes = SongInfo.ProviderType != MusicType.Normal ? 5 : 9;
|
||||||
while (!prebufferingComplete && bufferAttempts++ < toAttemptTimes)
|
while (!prebufferingComplete && bufferAttempts++ < toAttemptTimes)
|
||||||
{
|
{
|
||||||
await Task.Delay(waitPerAttempt, cancelToken);
|
await Task.Delay(waitPerAttempt, cancelToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
cancelToken.ThrowIfCancellationRequested();
|
cancelToken.ThrowIfCancellationRequested();
|
||||||
Console.WriteLine($"Prebuffering done? in {waitPerAttempt * bufferAttempts}");
|
Console.WriteLine($"Prebuffering done? in {waitPerAttempt * bufferAttempts}");
|
||||||
@ -158,12 +159,12 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await Task.Delay(100, cancelToken);
|
await Task.Delay(100, cancelToken).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
attempt = 0;
|
attempt = 0;
|
||||||
|
|
||||||
while (this.MusicPlayer.Paused)
|
while (this.MusicPlayer.Paused)
|
||||||
await Task.Delay(200, cancelToken);
|
await Task.Delay(200, cancelToken).ConfigureAwait(false);
|
||||||
buffer = AdjustVolume(buffer, MusicPlayer.Volume);
|
buffer = AdjustVolume(buffer, MusicPlayer.Volume);
|
||||||
voiceClient.Send(buffer, 0, read);
|
voiceClient.Send(buffer, 0, read);
|
||||||
}
|
}
|
||||||
@ -209,7 +210,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
if (musicType != MusicType.Local && IsRadioLink(query))
|
if (musicType != MusicType.Local && IsRadioLink(query))
|
||||||
{
|
{
|
||||||
musicType = MusicType.Radio;
|
musicType = MusicType.Radio;
|
||||||
query = await HandleStreamContainers(query) ?? query;
|
query = await HandleStreamContainers(query).ConfigureAwait(false) ?? query;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -237,7 +238,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
}
|
}
|
||||||
if (SoundCloud.Default.IsSoundCloudLink(query))
|
if (SoundCloud.Default.IsSoundCloudLink(query))
|
||||||
{
|
{
|
||||||
var svideo = await SoundCloud.Default.GetVideoAsync(query);
|
var svideo = await SoundCloud.Default.GetVideoAsync(query).ConfigureAwait(false);
|
||||||
return new Song(new SongInfo
|
return new Song(new SongInfo
|
||||||
{
|
{
|
||||||
Title = svideo.FullName,
|
Title = svideo.FullName,
|
||||||
@ -247,10 +248,10 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
Query = query,
|
Query = query,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var link = await SearchHelper.FindYoutubeUrlByKeywords(query);
|
var link = await SearchHelper.FindYoutubeUrlByKeywords(query).ConfigureAwait(false);
|
||||||
if (link == String.Empty)
|
if (link == String.Empty)
|
||||||
throw new OperationCanceledException("Not a valid youtube query.");
|
throw new OperationCanceledException("Not a valid youtube query.");
|
||||||
var allVideos = await Task.Factory.StartNew(async () => await YouTube.Default.GetAllVideosAsync(link)).Unwrap();
|
var allVideos = await Task.Factory.StartNew(async () => await YouTube.Default.GetAllVideosAsync(link).ConfigureAwait(false)).Unwrap().ConfigureAwait(false);
|
||||||
var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio);
|
var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio);
|
||||||
var video = videos
|
var video = videos
|
||||||
.Where(v => v.AudioBitrate < 192)
|
.Where(v => v.AudioBitrate < 192)
|
||||||
@ -280,7 +281,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
string file = null;
|
string file = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = await SearchHelper.GetResponseStringAsync(query);
|
file = await SearchHelper.GetResponseStringAsync(query).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.SoundCloudClientID))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.SoundCloudClientID))
|
||||||
throw new ArgumentNullException(nameof(NadekoBot.Creds.SoundCloudClientID));
|
throw new ArgumentNullException(nameof(NadekoBot.Creds.SoundCloudClientID));
|
||||||
|
|
||||||
var response = await SearchHelper.GetResponseStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={NadekoBot.Creds.SoundCloudClientID}");
|
var response = await SearchHelper.GetResponseStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={NadekoBot.Creds.SoundCloudClientID}").ConfigureAwait(false);
|
||||||
|
|
||||||
var responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject<SoundCloudVideo>(response);
|
var responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject<SoundCloudVideo>(response);
|
||||||
if (responseObj?.Kind != "track")
|
if (responseObj?.Kind != "track")
|
||||||
|
@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
MusicPlayer musicPlayer;
|
MusicPlayer musicPlayer;
|
||||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
|
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
|
||||||
musicPlayer.Stop();
|
musicPlayer.Stop();
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("d")
|
cgb.CreateCommand("d")
|
||||||
@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
MusicPlayer musicPlayer;
|
MusicPlayer musicPlayer;
|
||||||
if (!MusicPlayers.TryRemove(e.Server, out musicPlayer)) return;
|
if (!MusicPlayers.TryRemove(e.Server, out musicPlayer)) return;
|
||||||
musicPlayer.Destroy();
|
musicPlayer.Destroy();
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("p")
|
cgb.CreateCommand("p")
|
||||||
@ -101,9 +101,9 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
|
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
|
||||||
musicPlayer.TogglePause();
|
musicPlayer.TogglePause();
|
||||||
if (musicPlayer.Paused)
|
if (musicPlayer.Paused)
|
||||||
await e.Channel.SendMessage("🎵`Music Player paused.`");
|
await e.Channel.SendMessage("🎵`Music Player paused.`").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("🎵`Music Player unpaused.`");
|
await e.Channel.SendMessage("🎵`Music Player unpaused.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("q")
|
cgb.CreateCommand("q")
|
||||||
@ -113,11 +113,11 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("query", ParameterType.Unparsed)
|
.Parameter("query", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await QueueSong(e.Channel, e.User.VoiceChannel, e.GetArg("query"));
|
await QueueSong(e.Channel, e.User.VoiceChannel, e.GetArg("query")).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
await e.Message.Delete();
|
await e.Message.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
MusicPlayer musicPlayer;
|
MusicPlayer musicPlayer;
|
||||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("🎵 No active music player.");
|
await e.Channel.SendMessage("🎵 No active music player.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var currentSong = musicPlayer.CurrentSong;
|
var currentSong = musicPlayer.CurrentSong;
|
||||||
@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
else
|
else
|
||||||
toSend += "\n";
|
toSend += "\n";
|
||||||
var number = 1;
|
var number = 1;
|
||||||
await e.Channel.SendMessage(toSend + string.Join("\n", musicPlayer.Playlist.Take(15).Select(v => $"`{number++}.` {v.PrettyName}")));
|
await e.Channel.SendMessage(toSend + string.Join("\n", musicPlayer.Playlist.Take(15).Select(v => $"`{number++}.` {v.PrettyName}"))).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("np")
|
cgb.CreateCommand("np")
|
||||||
@ -161,7 +161,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (currentSong == null)
|
if (currentSong == null)
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage($"🎵`Now Playing` {currentSong.PrettyName} " +
|
await e.Channel.SendMessage($"🎵`Now Playing` {currentSong.PrettyName} " +
|
||||||
$"{currentSong.PrettyCurrentTime()}");
|
$"{currentSong.PrettyCurrentTime()}").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("vol")
|
cgb.CreateCommand("vol")
|
||||||
@ -176,11 +176,11 @@ namespace NadekoBot.Modules.Music
|
|||||||
int volume;
|
int volume;
|
||||||
if (!int.TryParse(arg, out volume))
|
if (!int.TryParse(arg, out volume))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Volume number invalid.");
|
await e.Channel.SendMessage("Volume number invalid.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
volume = musicPlayer.SetVolume(volume);
|
volume = musicPlayer.SetVolume(volume);
|
||||||
await e.Channel.SendMessage($"🎵 `Volume set to {volume}%`");
|
await e.Channel.SendMessage($"🎵 `Volume set to {volume}%`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("dv")
|
cgb.CreateCommand("dv")
|
||||||
@ -194,11 +194,11 @@ namespace NadekoBot.Modules.Music
|
|||||||
float volume;
|
float volume;
|
||||||
if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100)
|
if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Volume number invalid.");
|
await e.Channel.SendMessage("Volume number invalid.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DefaultMusicVolumes.AddOrUpdate(e.Server.Id, volume / 100, (key, newval) => volume / 100);
|
DefaultMusicVolumes.AddOrUpdate(e.Server.Id, volume / 100, (key, newval) => volume / 100);
|
||||||
await e.Channel.SendMessage($"🎵 `Default volume set to {volume}%`");
|
await e.Channel.SendMessage($"🎵 `Default volume set to {volume}%`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("min").Alias("mute")
|
cgb.CreateCommand("min").Alias("mute")
|
||||||
@ -240,12 +240,12 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
if (musicPlayer.Playlist.Count < 2)
|
if (musicPlayer.Playlist.Count < 2)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Not enough songs in order to perform the shuffle.");
|
await e.Channel.SendMessage("💢 Not enough songs in order to perform the shuffle.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
musicPlayer.Shuffle();
|
musicPlayer.Shuffle();
|
||||||
await e.Channel.SendMessage("🎵 `Songs shuffled.`");
|
await e.Channel.SendMessage("🎵 `Songs shuffled.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("pl")
|
cgb.CreateCommand("pl")
|
||||||
@ -258,24 +258,24 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
if (e.User.VoiceChannel?.Server != e.Server)
|
if (e.User.VoiceChannel?.Server != e.Server)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.");
|
await e.Channel.SendMessage("💢 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;
|
return;
|
||||||
}
|
}
|
||||||
var ids = await SearchHelper.GetVideoIDs(await SearchHelper.GetPlaylistIdByKeyword(arg));
|
var ids = await SearchHelper.GetVideoIDs(await SearchHelper.GetPlaylistIdByKeyword(arg).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
//todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE
|
//todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE
|
||||||
var idArray = ids as string[] ?? ids.ToArray();
|
var idArray = ids as string[] ?? ids.ToArray();
|
||||||
var count = idArray.Count();
|
var count = idArray.Count();
|
||||||
var msg =
|
var msg =
|
||||||
await e.Channel.SendMessage($"🎵 `Attempting to queue {count} songs".SnPl(count) + "...`");
|
await e.Channel.SendMessage($"🎵 `Attempting to queue {count} songs".SnPl(count) + "...`").ConfigureAwait(false);
|
||||||
foreach (var id in idArray)
|
foreach (var id in idArray)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await QueueSong(e.Channel, e.User.VoiceChannel, id, true);
|
await QueueSong(e.Channel, e.User.VoiceChannel, id, true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
await msg.Edit("🎵 `Playlist queue complete.`");
|
await msg.Edit("🎵 `Playlist queue complete.`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("lopl")
|
cgb.CreateCommand("lopl")
|
||||||
@ -293,9 +293,9 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System));
|
.Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System));
|
||||||
foreach (var file in fileEnum)
|
foreach (var file in fileEnum)
|
||||||
{
|
{
|
||||||
await QueueSong(e.Channel, e.User.VoiceChannel, file.FullName, true, MusicType.Local);
|
await QueueSong(e.Channel, e.User.VoiceChannel, file.FullName, true, MusicType.Local).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage("🎵 `Directory queue complete.`");
|
await e.Channel.SendMessage("🎵 `Directory queue complete.`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
});
|
});
|
||||||
@ -307,14 +307,14 @@ namespace NadekoBot.Modules.Music
|
|||||||
{
|
{
|
||||||
if (e.User.VoiceChannel?.Server != e.Server)
|
if (e.User.VoiceChannel?.Server != e.Server)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.");
|
await e.Channel.SendMessage("💢 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;
|
return;
|
||||||
}
|
}
|
||||||
await QueueSong(e.Channel, e.User.VoiceChannel, e.GetArg("radio_link"), musicType: MusicType.Radio);
|
await QueueSong(e.Channel, e.User.VoiceChannel, e.GetArg("radio_link"), musicType: MusicType.Radio).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
await e.Message.Delete();
|
await e.Message.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
var arg = e.GetArg("path");
|
var arg = e.GetArg("path");
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
return;
|
return;
|
||||||
await QueueSong(e.Channel, e.User.VoiceChannel, e.GetArg("path"), musicType: MusicType.Local);
|
await QueueSong(e.Channel, e.User.VoiceChannel, e.GetArg("path"), musicType: MusicType.Local).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("mv")
|
cgb.CreateCommand("mv")
|
||||||
@ -355,7 +355,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (arg?.ToLower() == "all")
|
if (arg?.ToLower() == "all")
|
||||||
{
|
{
|
||||||
musicPlayer.ClearQueue();
|
musicPlayer.ClearQueue();
|
||||||
await e.Channel.SendMessage($"🎵`Queue cleared!`");
|
await e.Channel.SendMessage($"🎵`Queue cleared!`").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int num;
|
int num;
|
||||||
@ -367,7 +367,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
var song = (musicPlayer.Playlist as List<Song>)?[num - 1];
|
var song = (musicPlayer.Playlist as List<Song>)?[num - 1];
|
||||||
musicPlayer.RemoveSongAt(num - 1);
|
musicPlayer.RemoveSongAt(num - 1);
|
||||||
await e.Channel.SendMessage($"🎵**Track {song.PrettyName} at position `#{num}` has been removed.**");
|
await e.Channel.SendMessage($"🎵**Track {song.PrettyName} at position `#{num}` has been removed.**").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("cleanup")
|
cgb.CreateCommand("cleanup")
|
||||||
@ -402,7 +402,8 @@ namespace NadekoBot.Modules.Music
|
|||||||
var currentValue = musicPlayer.ToggleRepeatSong();
|
var currentValue = musicPlayer.ToggleRepeatSong();
|
||||||
await e.Channel.SendMessage(currentValue ?
|
await e.Channel.SendMessage(currentValue ?
|
||||||
$"🎵🔂`Repeating track:`{currentSong.PrettyName}" :
|
$"🎵🔂`Repeating track:`{currentSong.PrettyName}" :
|
||||||
$"🎵🔂`Current track repeat stopped.`");
|
$"🎵🔂`Current track repeat stopped.`")
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("rpl")
|
cgb.CreateCommand("rpl")
|
||||||
@ -414,7 +415,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
||||||
return;
|
return;
|
||||||
var currentValue = musicPlayer.ToggleRepeatPlaylist();
|
var currentValue = musicPlayer.ToggleRepeatPlaylist();
|
||||||
await e.Channel.SendMessage($"🎵🔁`Repeat playlist {(currentValue ? "enabled" : "disabled")}`");
|
await e.Channel.SendMessage($"🎵🔁`Repeat playlist {(currentValue ? "enabled" : "disabled")}`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("save")
|
cgb.CreateCommand("save")
|
||||||
@ -466,7 +467,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
SongInfoId = s.Id.Value
|
SongInfoId = s.Id.Value
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await e.Channel.SendMessage($"🎵 `Saved playlist as {name}-{playlist.Id}`");
|
await e.Channel.SendMessage($"🎵 `Saved playlist as {name}-{playlist.Id}`").ConfigureAwait(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -489,7 +490,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
var textCh = e.Channel;
|
var textCh = e.Channel;
|
||||||
if (voiceCh == null || voiceCh.Server != textCh.Server)
|
if (voiceCh == null || voiceCh.Server != textCh.Server)
|
||||||
{
|
{
|
||||||
await textCh.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.");
|
await textCh.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var name = e.GetArg("name")?.Trim().ToLowerInvariant();
|
var name = e.GetArg("name")?.Trim().ToLowerInvariant();
|
||||||
@ -511,7 +512,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
|
|
||||||
if (playlist == null)
|
if (playlist == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Can't find playlist under that name.");
|
await e.Channel.SendMessage("Can't find playlist under that name.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,12 +522,12 @@ namespace NadekoBot.Modules.Music
|
|||||||
var songInfos = psis.Select(psi => DbHandler.Instance
|
var songInfos = psis.Select(psi => DbHandler.Instance
|
||||||
.FindOne<DataModels.SongInfo>(si => si.Id == psi.SongInfoId));
|
.FindOne<DataModels.SongInfo>(si => si.Id == psi.SongInfoId));
|
||||||
|
|
||||||
await e.Channel.SendMessage($"`Attempting to load {songInfos.Count()} songs`");
|
await e.Channel.SendMessage($"`Attempting to load {songInfos.Count()} songs`").ConfigureAwait(false);
|
||||||
foreach (var si in songInfos)
|
foreach (var si in songInfos)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await QueueSong(textCh, voiceCh, si.Query, true, (MusicType)si.ProviderType);
|
await QueueSong(textCh, voiceCh, si.Query, true, (MusicType)si.ProviderType).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -568,7 +569,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (seconds.Length == 1)
|
if (seconds.Length == 1)
|
||||||
seconds = "0" + seconds;
|
seconds = "0" + seconds;
|
||||||
|
|
||||||
await e.Channel.SendMessage($"`Skipped to {minutes}:{seconds}`");
|
await e.Channel.SendMessage($"`Skipped to {minutes}:{seconds}`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -578,7 +579,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (voiceCh == null || voiceCh.Server != textCh.Server)
|
if (voiceCh == null || voiceCh.Server != textCh.Server)
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
await textCh.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.");
|
await textCh.SendMessage("💢 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));
|
throw new ArgumentNullException(nameof(voiceCh));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
|
if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
|
||||||
@ -602,10 +603,10 @@ namespace NadekoBot.Modules.Music
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (lastFinishedMessage != null)
|
if (lastFinishedMessage != null)
|
||||||
await lastFinishedMessage.Delete();
|
await lastFinishedMessage.Delete().ConfigureAwait(false);
|
||||||
if (playingMessage != null)
|
if (playingMessage != null)
|
||||||
await playingMessage.Delete();
|
await playingMessage.Delete().ConfigureAwait(false);
|
||||||
lastFinishedMessage = await textCh.SendMessage($"🎵`Finished`{song.PrettyName}");
|
lastFinishedMessage = await textCh.SendMessage($"🎵`Finished`{song.PrettyName}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -622,30 +623,30 @@ namespace NadekoBot.Modules.Music
|
|||||||
{
|
{
|
||||||
|
|
||||||
var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(sender.Volume * 100)}%`";
|
var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(sender.Volume * 100)}%`";
|
||||||
playingMessage = await textCh.SendMessage(msgTxt);
|
playingMessage = await textCh.SendMessage(msgTxt).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return mp;
|
return mp;
|
||||||
});
|
});
|
||||||
var resolvedSong = await Song.ResolveSong(query, musicType);
|
var resolvedSong = await Song.ResolveSong(query, musicType).ConfigureAwait(false);
|
||||||
resolvedSong.MusicPlayer = musicPlayer;
|
resolvedSong.MusicPlayer = musicPlayer;
|
||||||
|
|
||||||
musicPlayer.AddSong(resolvedSong);
|
musicPlayer.AddSong(resolvedSong);
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
var queuedMessage = await textCh.SendMessage($"🎵`Queued`{resolvedSong.PrettyName} **at** `#{musicPlayer.Playlist.Count}`");
|
var queuedMessage = await textCh.SendMessage($"🎵`Queued`{resolvedSong.PrettyName} **at** `#{musicPlayer.Playlist.Count}`").ConfigureAwait(false);
|
||||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await Task.Delay(10000);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await queuedMessage.Delete();
|
await queuedMessage.Delete().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,10 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var tag = e.GetArg("tag")?.Trim() ?? "";
|
var tag = e.GetArg("tag")?.Trim() ?? "";
|
||||||
await e.Channel.SendMessage(":heart: Gelbooru: " + await SearchHelper.GetGelbooruImageLink("rating%3Aexplicit+" + tag));
|
await e.Channel.SendMessage(":heart: Gelbooru: " + await SearchHelper.GetGelbooruImageLink("rating%3Aexplicit+" + tag).ConfigureAwait(false))
|
||||||
await e.Channel.SendMessage(":heart: Danbooru: " + await SearchHelper.GetDanbooruImageLink("rating%3Aexplicit+" + tag));
|
.ConfigureAwait(false);
|
||||||
|
await e.Channel.SendMessage(":heart: Danbooru: " + await SearchHelper.GetDanbooruImageLink("rating%3Aexplicit+" + tag).ConfigureAwait(false))
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "danbooru")
|
cgb.CreateCommand(Prefix + "danbooru")
|
||||||
.Description("Shows a random hentai image from danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~danbooru yuri+kissing")
|
.Description("Shows a random hentai image from danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~danbooru yuri+kissing")
|
||||||
@ -36,7 +38,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var tag = e.GetArg("tag")?.Trim() ?? "";
|
var tag = e.GetArg("tag")?.Trim() ?? "";
|
||||||
await e.Channel.SendMessage(await SearchHelper.GetDanbooruImageLink(tag));
|
await e.Channel.SendMessage(await SearchHelper.GetDanbooruImageLink(tag).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "gelbooru")
|
cgb.CreateCommand(Prefix + "gelbooru")
|
||||||
.Description("Shows a random hentai image from gelbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~gelbooru yuri+kissing")
|
.Description("Shows a random hentai image from gelbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~gelbooru yuri+kissing")
|
||||||
@ -44,7 +46,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var tag = e.GetArg("tag")?.Trim() ?? "";
|
var tag = e.GetArg("tag")?.Trim() ?? "";
|
||||||
await e.Channel.SendMessage(await SearchHelper.GetGelbooruImageLink(tag));
|
await e.Channel.SendMessage(await SearchHelper.GetGelbooruImageLink(tag).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "safebooru")
|
cgb.CreateCommand(Prefix + "safebooru")
|
||||||
.Description("Shows a random image from safebooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~safebooru yuri+kissing")
|
.Description("Shows a random image from safebooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~safebooru yuri+kissing")
|
||||||
@ -52,7 +54,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var tag = e.GetArg("tag")?.Trim() ?? "";
|
var tag = e.GetArg("tag")?.Trim() ?? "";
|
||||||
await e.Channel.SendMessage(await SearchHelper.GetSafebooruImageLink(tag));
|
await e.Channel.SendMessage(await SearchHelper.GetSafebooruImageLink(tag).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "rule34")
|
cgb.CreateCommand(Prefix + "rule34")
|
||||||
.Description("Shows a random image from rule34.xx with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~gelbooru yuri+kissing")
|
.Description("Shows a random image from rule34.xx with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~gelbooru yuri+kissing")
|
||||||
@ -60,7 +62,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var tag = e.GetArg("tag")?.Trim() ?? "";
|
var tag = e.GetArg("tag")?.Trim() ?? "";
|
||||||
await e.Channel.SendMessage(await SearchHelper.GetRule34ImageLink(tag));
|
await e.Channel.SendMessage(await SearchHelper.GetRule34ImageLink(tag).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "e621")
|
cgb.CreateCommand(Prefix + "e621")
|
||||||
.Description("Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags.\n**Usage**: ~e621 yuri+kissing")
|
.Description("Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags.\n**Usage**: ~e621 yuri+kissing")
|
||||||
@ -68,14 +70,14 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var tag = e.GetArg("tag")?.Trim() ?? "";
|
var tag = e.GetArg("tag")?.Trim() ?? "";
|
||||||
await e.Channel.SendMessage(await SearchHelper.GetE621ImageLink(tag));
|
await e.Channel.SendMessage(await SearchHelper.GetE621ImageLink(tag).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "cp")
|
cgb.CreateCommand(Prefix + "cp")
|
||||||
.Description("We all know where this will lead you to.")
|
.Description("We all know where this will lead you to.")
|
||||||
.Parameter("anything", ParameterType.Unparsed)
|
.Parameter("anything", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("http://i.imgur.com/MZkY1md.jpg");
|
await e.Channel.SendMessage("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "boobs")
|
cgb.CreateCommand(Prefix + "boobs")
|
||||||
.Description("Real adult content.")
|
.Description("Real adult content.")
|
||||||
@ -83,12 +85,12 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var obj = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.oboobs.ru/boobs/{rng.Next(0, 9380)}"))[0];
|
var obj = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.oboobs.ru/boobs/{rng.Next(0, 9380)}").ConfigureAwait(false))[0];
|
||||||
await e.Channel.SendMessage($"http://media.oboobs.ru/{ obj["preview"].ToString() }");
|
await e.Channel.SendMessage($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 {ex.Message}");
|
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "butts")
|
cgb.CreateCommand(Prefix + "butts")
|
||||||
@ -98,12 +100,12 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var obj = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.obutts.ru/butts/{rng.Next(0, 3373)}"))[0];
|
var obj = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.obutts.ru/butts/{rng.Next(0, 3373)}").ConfigureAwait(false))[0];
|
||||||
await e.Channel.SendMessage($"http://media.obutts.ru/{ obj["preview"].ToString() }");
|
await e.Channel.SendMessage($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 {ex.Message}");
|
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ namespace NadekoBot.Modules.Permissions.Classes
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
//blacklist is cleared every 1.75 seconds. That is the most time anyone will be blocked
|
//blacklist is cleared every 1.75 seconds. That is the most time anyone will be blocked
|
||||||
await Task.Delay(1750);
|
await Task.Delay(1750).ConfigureAwait(false);
|
||||||
timeBlackList.Clear();
|
timeBlackList.Clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -24,13 +24,14 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
|
|
||||||
if (filterRegex.IsMatch(args.Message.RawText))
|
if (filterRegex.IsMatch(args.Message.RawText))
|
||||||
{
|
{
|
||||||
await args.Message.Delete();
|
await args.Message.Delete().ConfigureAwait(false);
|
||||||
IncidentsHandler.Add(args.Server.Id, $"User [{args.User.Name}/{args.User.Id}] posted " +
|
IncidentsHandler.Add(args.Server.Id, $"User [{args.User.Name}/{args.User.Id}] posted " +
|
||||||
$"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
|
$"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
|
||||||
$"Full message: [[{args.Message.Text}]]");
|
$"Full message: [[{args.Message.Text}]]");
|
||||||
if (serverPerms.Verbose)
|
if (serverPerms.Verbose)
|
||||||
await args.Channel.SendMessage($"{args.User.Mention} Invite links are not " +
|
await args.Channel.SendMessage($"{args.User.Mention} Invite links are not " +
|
||||||
$"allowed on this channel.");
|
$"allowed on this channel.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@ -71,7 +72,8 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
? e.Channel
|
? e.Channel
|
||||||
: PermissionHelper.ValidateChannel(e.Server, chanStr);
|
: PermissionHelper.ValidateChannel(e.Server, chanStr);
|
||||||
PermissionsHandler.SetChannelFilterInvitesPermission(chan, state);
|
PermissionsHandler.SetChannelFilterInvitesPermission(chan, state);
|
||||||
await e.Channel.SendMessage($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.");
|
await e.Channel.SendMessage($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//all channels
|
//all channels
|
||||||
@ -80,12 +82,14 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetChannelFilterInvitesPermission(curChannel, state);
|
PermissionsHandler.SetChannelFilterInvitesPermission(curChannel, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.");
|
await e.Channel.SendMessage($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error: {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error: {ex.Message}")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -99,12 +103,13 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
PermissionsHandler.SetServerFilterInvitesPermission(e.Server, state);
|
PermissionsHandler.SetServerFilterInvitesPermission(e.Server, state);
|
||||||
await e.Channel.SendMessage($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for this server.");
|
await e.Channel.SendMessage($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for this server.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error: {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error: {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,14 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
var wordsInMessage = args.Message.RawText.ToLowerInvariant().Split(' ');
|
var wordsInMessage = args.Message.RawText.ToLowerInvariant().Split(' ');
|
||||||
if (serverPerms.Words.Any(w => wordsInMessage.Contains(w)))
|
if (serverPerms.Words.Any(w => wordsInMessage.Contains(w)))
|
||||||
{
|
{
|
||||||
await args.Message.Delete();
|
await args.Message.Delete().ConfigureAwait(false);
|
||||||
IncidentsHandler.Add(args.Server.Id, $"User [{args.User.Name}/{args.User.Id}] posted " +
|
IncidentsHandler.Add(args.Server.Id, $"User [{args.User.Name}/{args.User.Id}] posted " +
|
||||||
$"BANNED WORD in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
|
$"BANNED WORD in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
|
||||||
$"Full message: [[{args.Message.Text}]]");
|
$"Full message: [[{args.Message.Text}]]");
|
||||||
if (serverPerms.Verbose)
|
if (serverPerms.Verbose)
|
||||||
await args.Channel.SendMessage($"{args.User.Mention} One or more of the words you used " +
|
await args.Channel.SendMessage($"{args.User.Mention} One or more of the words you used " +
|
||||||
$"in that sentence are not allowed here.");
|
$"in that sentence are not allowed here.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@ -68,7 +69,7 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
? e.Channel
|
? e.Channel
|
||||||
: PermissionHelper.ValidateChannel(e.Server, chanStr);
|
: PermissionHelper.ValidateChannel(e.Server, chanStr);
|
||||||
PermissionsHandler.SetChannelWordPermission(chan, state);
|
PermissionsHandler.SetChannelWordPermission(chan, state);
|
||||||
await e.Channel.SendMessage($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.");
|
await e.Channel.SendMessage($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//all channels
|
//all channels
|
||||||
@ -77,11 +78,11 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetChannelWordPermission(curChannel, state);
|
PermissionsHandler.SetChannelWordPermission(curChannel, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.");
|
await e.Channel.SendMessage($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error: {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error: {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -98,12 +99,12 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
if (string.IsNullOrWhiteSpace(word))
|
if (string.IsNullOrWhiteSpace(word))
|
||||||
return;
|
return;
|
||||||
PermissionsHandler.AddFilteredWord(e.Server, word.ToLowerInvariant().Trim());
|
PermissionsHandler.AddFilteredWord(e.Server, word.ToLowerInvariant().Trim());
|
||||||
await e.Channel.SendMessage($"Successfully added new filtered word.");
|
await e.Channel.SendMessage($"Successfully added new filtered word.").ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error: {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error: {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -120,12 +121,12 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
if (string.IsNullOrWhiteSpace(word))
|
if (string.IsNullOrWhiteSpace(word))
|
||||||
return;
|
return;
|
||||||
PermissionsHandler.RemoveFilteredWord(e.Server, word.ToLowerInvariant().Trim());
|
PermissionsHandler.RemoveFilteredWord(e.Server, word.ToLowerInvariant().Trim());
|
||||||
await e.Channel.SendMessage($"Successfully removed filtered word.");
|
await e.Channel.SendMessage($"Successfully removed filtered word.").ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error: {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error: {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -141,11 +142,11 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
if (!PermissionsHandler.PermissionsDict.TryGetValue(e.Server.Id, out serverPerms))
|
if (!PermissionsHandler.PermissionsDict.TryGetValue(e.Server.Id, out serverPerms))
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage($"There are `{serverPerms.Words.Count}` filtered words.\n" +
|
await e.Channel.SendMessage($"There are `{serverPerms.Words.Count}` filtered words.\n" +
|
||||||
string.Join("\n", serverPerms.Words));
|
string.Join("\n", serverPerms.Words)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error: {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error: {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -159,12 +160,13 @@ namespace NadekoBot.Modules.Permissions.Commands
|
|||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
PermissionsHandler.SetServerWordPermission(e.Server, state);
|
PermissionsHandler.SetServerWordPermission(e.Server, state);
|
||||||
await e.Channel.SendMessage($"Word filtering has been **{(state ? "enabled" : "disabled")}** on this server.");
|
await e.Channel.SendMessage($"Word filtering has been **{(state ? "enabled" : "disabled")}** on this server.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error: {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error: {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("role")))
|
if (string.IsNullOrWhiteSpace(e.GetArg("role")))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"Current permissions role is `{PermissionsHandler.GetServerPermissionsRoleName(e.Server)}`");
|
await e.Channel.SendMessage($"Current permissions role is `{PermissionsHandler.GetServerPermissionsRoleName(e.Server)}`").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,11 +51,11 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
await e.Channel.SendMessage($"Role `{arg}` probably doesn't exist. Create the role with that name first.");
|
await e.Channel.SendMessage($"Role `{arg}` probably doesn't exist. Create the role with that name first.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PermissionsHandler.SetPermissionsRole(e.Server, role.Name);
|
PermissionsHandler.SetPermissionsRole(e.Server, role.Name);
|
||||||
await e.Channel.SendMessage($"Role `{role.Name}` is now required in order to change permissions.");
|
await e.Channel.SendMessage($"Role `{role.Name}` is now required in order to change permissions.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "verbose")
|
cgb.CreateCommand(Prefix + "verbose")
|
||||||
@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var arg = e.GetArg("arg");
|
var arg = e.GetArg("arg");
|
||||||
var val = PermissionHelper.ValidateBool(arg);
|
var val = PermissionHelper.ValidateBool(arg);
|
||||||
PermissionsHandler.SetVerbosity(e.Server, val);
|
PermissionsHandler.SetVerbosity(e.Server, val);
|
||||||
await e.Channel.SendMessage($"Verbosity set to {val}.");
|
await e.Channel.SendMessage($"Verbosity set to {val}.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "serverperms")
|
cgb.CreateCommand(Prefix + "serverperms")
|
||||||
@ -77,8 +77,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
var perms = PermissionsHandler.GetServerPermissions(e.Server);
|
var perms = PermissionsHandler.GetServerPermissions(e.Server);
|
||||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||||
await e.Channel.SendMessage("No permissions set for this server.");
|
await e.Channel.SendMessage("No permissions set for this server.").ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage(perms.ToString());
|
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "roleperms")
|
cgb.CreateCommand(Prefix + "roleperms")
|
||||||
@ -96,15 +96,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Error: " + ex.Message);
|
await e.Channel.SendMessage("💢 Error: " + ex.Message).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var perms = PermissionsHandler.GetRolePermissionsById(e.Server, role.Id);
|
var perms = PermissionsHandler.GetRolePermissionsById(e.Server, role.Id);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||||
await e.Channel.SendMessage($"No permissions set for **{role.Name}** role.");
|
await e.Channel.SendMessage($"No permissions set for **{role.Name}** role.").ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage(perms.ToString());
|
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "channelperms")
|
cgb.CreateCommand(Prefix + "channelperms")
|
||||||
@ -122,14 +122,14 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Error: " + ex.Message);
|
await e.Channel.SendMessage("💢 Error: " + ex.Message).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var perms = PermissionsHandler.GetChannelPermissionsById(e.Server, channel.Id);
|
var perms = PermissionsHandler.GetChannelPermissionsById(e.Server, channel.Id);
|
||||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||||
await e.Channel.SendMessage($"No permissions set for **{channel.Name}** channel.");
|
await e.Channel.SendMessage($"No permissions set for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage(perms.ToString());
|
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "userperms")
|
cgb.CreateCommand(Prefix + "userperms")
|
||||||
@ -146,14 +146,14 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Error: " + ex.Message);
|
await e.Channel.SendMessage("💢 Error: " + ex.Message).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var perms = PermissionsHandler.GetUserPermissionsById(e.Server, user.Id);
|
var perms = PermissionsHandler.GetUserPermissionsById(e.Server, user.Id);
|
||||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||||
await e.Channel.SendMessage($"No permissions set for user **{user.Name}**.");
|
await e.Channel.SendMessage($"No permissions set for user **{user.Name}**.").ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage(perms.ToString());
|
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "sm").Alias(Prefix + "servermodule")
|
cgb.CreateCommand(Prefix + "sm").Alias(Prefix + "servermodule")
|
||||||
@ -168,15 +168,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
|
|
||||||
PermissionsHandler.SetServerModulePermission(e.Server, module, state);
|
PermissionsHandler.SetServerModulePermission(e.Server, module, state);
|
||||||
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.");
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -192,15 +192,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
|
|
||||||
PermissionsHandler.SetServerCommandPermission(e.Server, command, state);
|
PermissionsHandler.SetServerCommandPermission(e.Server, command, state);
|
||||||
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.");
|
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -222,23 +222,23 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetRoleModulePermission(role, module, state);
|
PermissionsHandler.SetRoleModulePermission(role, module, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.");
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
||||||
|
|
||||||
PermissionsHandler.SetRoleModulePermission(role, module, state);
|
PermissionsHandler.SetRoleModulePermission(role, module, state);
|
||||||
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -260,23 +260,23 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetRoleCommandPermission(role, command, state);
|
PermissionsHandler.SetRoleCommandPermission(role, command, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.");
|
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
||||||
|
|
||||||
PermissionsHandler.SetRoleCommandPermission(role, command, state);
|
PermissionsHandler.SetRoleCommandPermission(role, command, state);
|
||||||
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
|
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -298,23 +298,23 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetChannelModulePermission(channel, module, state);
|
PermissionsHandler.SetChannelModulePermission(channel, module, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.");
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
||||||
|
|
||||||
PermissionsHandler.SetChannelModulePermission(channel, module, state);
|
PermissionsHandler.SetChannelModulePermission(channel, module, state);
|
||||||
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -336,23 +336,23 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetChannelCommandPermission(channel, command, state);
|
PermissionsHandler.SetChannelCommandPermission(channel, command, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.");
|
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
||||||
|
|
||||||
PermissionsHandler.SetChannelCommandPermission(channel, command, state);
|
PermissionsHandler.SetChannelCommandPermission(channel, command, state);
|
||||||
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
|
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -370,15 +370,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
||||||
|
|
||||||
PermissionsHandler.SetUserModulePermission(user, module, state);
|
PermissionsHandler.SetUserModulePermission(user, module, state);
|
||||||
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.");
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -396,15 +396,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
||||||
|
|
||||||
PermissionsHandler.SetUserCommandPermission(user, command, state);
|
PermissionsHandler.SetUserCommandPermission(user, command, state);
|
||||||
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.");
|
await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -421,15 +421,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetServerModulePermission(e.Server, module.Name, state);
|
PermissionsHandler.SetServerModulePermission(e.Server, module.Name, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** on this server.");
|
await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -448,15 +448,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetServerCommandPermission(e.Server, command.Text, state);
|
PermissionsHandler.SetServerCommandPermission(e.Server, command.Text, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.");
|
await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -475,15 +475,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
PermissionsHandler.SetChannelModulePermission(channel, module.Name, state);
|
PermissionsHandler.SetChannelModulePermission(channel, module.Name, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
|
await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -503,15 +503,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetChannelCommandPermission(channel, command.Text, state);
|
PermissionsHandler.SetChannelCommandPermission(channel, command.Text, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
|
await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -530,15 +530,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
PermissionsHandler.SetRoleModulePermission(role, module.Name, state);
|
PermissionsHandler.SetRoleModulePermission(role, module.Name, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
|
await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -558,15 +558,15 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
PermissionsHandler.SetRoleCommandPermission(role, command.Text, state);
|
PermissionsHandler.SetRoleCommandPermission(role, command.Text, state);
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
|
await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (ArgumentException exArg)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -582,8 +582,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var usr = e.Message.MentionedUsers.First();
|
var usr = e.Message.MentionedUsers.First();
|
||||||
NadekoBot.Config.UserBlacklist.Add(usr.Id);
|
NadekoBot.Config.UserBlacklist.Add(usr.Id);
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
await e.Channel.SendMessage($"`Sucessfully blacklisted user {usr.Name}`");
|
await e.Channel.SendMessage($"`Sucessfully blacklisted user {usr.Name}`").ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "uubl")
|
cgb.CreateCommand(Prefix + "uubl")
|
||||||
@ -600,13 +600,13 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
NadekoBot.Config.UserBlacklist.Remove(usr.Id);
|
NadekoBot.Config.UserBlacklist.Remove(usr.Id);
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
await e.Channel.SendMessage($"`Sucessfully unblacklisted user {usr.Name}`");
|
await e.Channel.SendMessage($"`Sucessfully unblacklisted user {usr.Name}`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"`{usr.Name} was not in blacklist`");
|
await e.Channel.SendMessage($"`{usr.Name} was not in blacklist`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "cbl")
|
cgb.CreateCommand(Prefix + "cbl")
|
||||||
@ -620,8 +620,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var ch = e.Message.MentionedChannels.First();
|
var ch = e.Message.MentionedChannels.First();
|
||||||
NadekoBot.Config.UserBlacklist.Add(ch.Id);
|
NadekoBot.Config.UserBlacklist.Add(ch.Id);
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
await e.Channel.SendMessage($"`Sucessfully blacklisted channel {ch.Name}`");
|
await e.Channel.SendMessage($"`Sucessfully blacklisted channel {ch.Name}`").ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "cubl")
|
cgb.CreateCommand(Prefix + "cubl")
|
||||||
@ -635,8 +635,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
var ch = e.Message.MentionedChannels.First();
|
var ch = e.Message.MentionedChannels.First();
|
||||||
NadekoBot.Config.UserBlacklist.Remove(ch.Id);
|
NadekoBot.Config.UserBlacklist.Remove(ch.Id);
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
await e.Channel.SendMessage($"`Sucessfully blacklisted channel {ch.Name}`");
|
await e.Channel.SendMessage($"`Sucessfully blacklisted channel {ch.Name}`").ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "sbl")
|
cgb.CreateCommand(Prefix + "sbl")
|
||||||
@ -654,7 +654,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
NadekoBot.Client.FindServers(arg.Trim()).FirstOrDefault();
|
NadekoBot.Client.FindServers(arg.Trim()).FirstOrDefault();
|
||||||
if (server == null)
|
if (server == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Cannot find that server");
|
await e.Channel.SendMessage("Cannot find that server").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var serverId = server.Id;
|
var serverId = server.Id;
|
||||||
@ -666,8 +666,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
TypingGame typeracer;
|
TypingGame typeracer;
|
||||||
SpeedTyping.RunningContests.TryRemove(serverId, out typeracer);
|
SpeedTyping.RunningContests.TryRemove(serverId, out typeracer);
|
||||||
|
|
||||||
await e.Channel.SendMessage($"`Sucessfully blacklisted server {server.Name}`");
|
await e.Channel.SendMessage($"`Sucessfully blacklisted server {server.Name}`").ConfigureAwait(false);
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.Modules;
|
using Discord.Modules;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.DataModels;
|
|
||||||
using NadekoBot.Classes.JSONModels;
|
using NadekoBot.Classes.JSONModels;
|
||||||
|
using NadekoBot.DataModels;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Permissions.Classes;
|
using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
using System;
|
||||||
@ -92,12 +92,12 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
var target = e.Server.FindUsers(targetStr).FirstOrDefault();
|
var target = e.Server.FindUsers(targetStr).FirstOrDefault();
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("No such person.");
|
await e.Channel.SendMessage("No such person.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (target == e.User)
|
else if (target == e.User)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You can't attack yourself.");
|
await e.Channel.SendMessage("You can't attack yourself.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Checking stats first, then move
|
// Checking stats first, then move
|
||||||
@ -109,17 +109,17 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
//User not able if HP < 0, has made more than 4 attacks
|
//User not able if HP < 0, has made more than 4 attacks
|
||||||
if (userStats.Hp < 0)
|
if (userStats.Hp < 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} has fainted and was not able to move!");
|
await e.Channel.SendMessage($"{e.User.Mention} has fainted and was not able to move!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (userStats.MovesMade >= 5)
|
if (userStats.MovesMade >= 5)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} has used too many moves in a row and was not able to move!");
|
await e.Channel.SendMessage($"{e.User.Mention} has used too many moves in a row and was not able to move!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (userStats.LastAttacked.Contains(target.Id))
|
if (userStats.LastAttacked.Contains(target.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} can't attack again without retaliation!");
|
await e.Channel.SendMessage($"{e.User.Mention} can't attack again without retaliation!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//get target stats
|
//get target stats
|
||||||
@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
//If target's HP is below 0, no use attacking
|
//If target's HP is below 0, no use attacking
|
||||||
if (targetStats.Hp <= 0)
|
if (targetStats.Hp <= 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{target.Mention} has already fainted!");
|
await e.Channel.SendMessage($"{target.Mention} has already fainted!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
var enabledMoves = userType.Moves;
|
var enabledMoves = userType.Moves;
|
||||||
if (!enabledMoves.Contains(move.ToLowerInvariant()))
|
if (!enabledMoves.Contains(move.ToLowerInvariant()))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use `{Prefix}ml` to see moves you can use");
|
await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use `{Prefix}ml` to see moves you can use").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
Stats[e.User.Id] = userStats;
|
Stats[e.User.Id] = userStats;
|
||||||
Stats[target.Id] = targetStats;
|
Stats[target.Id] = targetStats;
|
||||||
|
|
||||||
await e.Channel.SendMessage(response);
|
await e.Channel.SendMessage(response).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "ml")
|
cgb.CreateCommand(Prefix + "ml")
|
||||||
@ -206,7 +206,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
{
|
{
|
||||||
str += $"\n{userType.Icon}{m}";
|
str += $"\n{userType.Icon}{m}";
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(str);
|
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "heal")
|
cgb.CreateCommand(Prefix + "heal")
|
||||||
@ -220,7 +220,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
var usr = e.Server.FindUsers(targetStr).FirstOrDefault();
|
var usr = e.Server.FindUsers(targetStr).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("No such person.");
|
await e.Channel.SendMessage("No such person.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Stats.ContainsKey(usr.Id))
|
if (Stats.ContainsKey(usr.Id))
|
||||||
@ -230,7 +230,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
int HP = targetStats.Hp;
|
int HP = targetStats.Hp;
|
||||||
if (targetStats.Hp == targetStats.MaxHp)
|
if (targetStats.Hp == targetStats.MaxHp)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{usr.Name} already has full HP!");
|
await e.Channel.SendMessage($"{usr.Name} already has full HP!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Payment~
|
//Payment~
|
||||||
@ -238,7 +238,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
||||||
if (pts < amount)
|
if (pts < amount)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!");
|
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name;
|
var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name;
|
||||||
@ -249,16 +249,16 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
{
|
{
|
||||||
//Could heal only for half HP?
|
//Could heal only for half HP?
|
||||||
Stats[usr.Id].Hp = (targetStats.MaxHp / 2);
|
Stats[usr.Id].Hp = (targetStats.MaxHp / 2);
|
||||||
await e.Channel.SendMessage($"{e.User.Name} revived {usr.Name} with one {NadekoBot.Config.CurrencySign}");
|
await e.Channel.SendMessage($"{e.User.Name} revived {usr.Name} with one {NadekoBot.Config.CurrencySign}").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]);
|
var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]);
|
||||||
await e.Channel.SendMessage($"{e.User.Name} healed {usr.Name} for {targetStats.MaxHp - HP} HP with {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencySign}");
|
await e.Channel.SendMessage($"{e.User.Name} healed {usr.Name} for {targetStats.MaxHp - HP} HP with {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencySign}").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{usr.Name} already has full HP!");
|
await e.Channel.SendMessage($"{usr.Name} already has full HP!").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -273,11 +273,11 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
var usr = e.Server.FindUsers(usrStr).FirstOrDefault();
|
var usr = e.Server.FindUsers(usrStr).FirstOrDefault();
|
||||||
if (usr == null)
|
if (usr == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("No such person.");
|
await e.Channel.SendMessage("No such person.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pType = GetPokeType(usr.Id);
|
var pType = GetPokeType(usr.Id);
|
||||||
await e.Channel.SendMessage($"Type of {usr.Name} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}");
|
await e.Channel.SendMessage($"Type of {usr.Name} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -292,12 +292,12 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
var targetType = stringToPokemonType(targetTypeStr);
|
var targetType = stringToPokemonType(targetTypeStr);
|
||||||
if (targetType == null)
|
if (targetType == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Invalid type specified. Type must be one of:\nNORMAL, FIRE, WATER, ELECTRIC, GRASS, ICE, FIGHTING, POISON, GROUND, FLYING, PSYCHIC, BUG, ROCK, GHOST, DRAGON, DARK, STEEL");
|
await e.Channel.SendMessage("Invalid type specified. Type must be one of:\nNORMAL, FIRE, WATER, ELECTRIC, GRASS, ICE, FIGHTING, POISON, GROUND, FLYING, PSYCHIC, BUG, ROCK, GHOST, DRAGON, DARK, STEEL").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (targetType == GetPokeType(e.User.Id))
|
if (targetType == GetPokeType(e.User.Id))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Icon}");
|
await e.Channel.SendMessage($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Icon}").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
var pts = DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
var pts = DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
||||||
if (pts < amount)
|
if (pts < amount)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!");
|
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough {NadekoBot.Config.CurrencyName}s! \nYou still need {amount - pts} {NadekoBot.Config.CurrencySign} to be able to do this!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FlowersHandler.RemoveFlowers(e.User, $"set usertype to {targetTypeStr}", amount);
|
FlowersHandler.RemoveFlowers(e.User, $"set usertype to {targetTypeStr}", amount);
|
||||||
@ -327,7 +327,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
|
|
||||||
//Now for the response
|
//Now for the response
|
||||||
|
|
||||||
await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeStr}{targetType.Icon} for a {NadekoBot.Config.CurrencySign}");
|
await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeStr}{targetType.Icon} for a {NadekoBot.Config.CurrencySign}").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
msg += curr + "; ";
|
msg += curr + "; ";
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage(msg);
|
await e.Channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
private Func<CommandEventArgs, Task> ConvertFunc() =>
|
private Func<CommandEventArgs, Task> ConvertFunc() =>
|
||||||
@ -69,7 +69,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Channel.SendIsTyping();
|
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||||
|
|
||||||
string from = e.GetArg("from-to").ToLowerInvariant().Split('>')[0];
|
string from = e.GetArg("from-to").ToLowerInvariant().Split('>')[0];
|
||||||
string to = e.GetArg("from-to").ToLowerInvariant().Split('>')[1];
|
string to = e.GetArg("from-to").ToLowerInvariant().Split('>')[1];
|
||||||
@ -88,20 +88,20 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
{
|
{
|
||||||
Unit inUnit = new Unit(fromCode, quantity, table);
|
Unit inUnit = new Unit(fromCode, quantity, table);
|
||||||
Unit outUnit = inUnit.Convert(toCode);
|
Unit outUnit = inUnit.Convert(toCode);
|
||||||
await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString());
|
await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reInitCurrencyConverterTable();
|
reInitCurrencyConverterTable();
|
||||||
Unit inUnit = currTable.CreateUnit(quantity, from.ToUpperInvariant());
|
Unit inUnit = currTable.CreateUnit(quantity, from.ToUpperInvariant());
|
||||||
Unit outUnit = inUnit.Convert(currTable.CurrencyCode(to.ToUpperInvariant()));
|
Unit outUnit = inUnit.Convert(currTable.CurrencyCode(to.ToUpperInvariant()));
|
||||||
await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString());
|
await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch //(Exception ex)
|
catch //(Exception ex)
|
||||||
{
|
{
|
||||||
//Console.WriteLine(ex.ToString());
|
//Console.WriteLine(ex.ToString());
|
||||||
await e.Channel.SendMessage("Bad input format, or sth went wrong... Try to list them with `" + Module.Prefix + "`convertlist");
|
await e.Channel.SendMessage("Bad input format, or sth went wrong... Try to list them with `" + Module.Prefix + "`convertlist").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,10 +86,10 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
if (champ != null)
|
if (champ != null)
|
||||||
{
|
{
|
||||||
champ.ImageStream.Position = 0;
|
champ.ImageStream.Position = 0;
|
||||||
await e.Channel.SendFile("champ.png", champ.ImageStream);
|
await e.Channel.SendFile("champ.png", champ.ImageStream).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var allData = JArray.Parse(await Classes.SearchHelper.GetResponseStringAsync($"http://api.champion.gg/champion/{name}?api_key={NadekoBot.Creds.LOLAPIKey}"));
|
var allData = JArray.Parse(await Classes.SearchHelper.GetResponseStringAsync($"http://api.champion.gg/champion/{name}?api_key={NadekoBot.Creds.LOLAPIKey}").ConfigureAwait(false));
|
||||||
JToken data = null;
|
JToken data = null;
|
||||||
if (role != null)
|
if (role != null)
|
||||||
{
|
{
|
||||||
@ -103,7 +103,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
}
|
}
|
||||||
if (data == null)
|
if (data == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Data for that role does not exist.");
|
await e.Channel.SendMessage("💢 Data for that role does not exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Sending lol image from cache.");
|
Console.WriteLine("Sending lol image from cache.");
|
||||||
champ.ImageStream.Position = 0;
|
champ.ImageStream.Position = 0;
|
||||||
await e.Channel.SendFile("champ.png", champ.ImageStream);
|
await e.Channel.SendFile("champ.png", champ.ImageStream).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//name = data["title"].ToString();
|
//name = data["title"].ToString();
|
||||||
@ -134,7 +134,8 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
roles[i] = ">" + roles[i] + "<";
|
roles[i] = ">" + roles[i] + "<";
|
||||||
}
|
}
|
||||||
var general = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.champion.gg/stats/" +
|
var general = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.champion.gg/stats/" +
|
||||||
$"champs/{name}?api_key={NadekoBot.Creds.LOLAPIKey}"))
|
$"champs/{name}?api_key={NadekoBot.Creds.LOLAPIKey}")
|
||||||
|
.ConfigureAwait(false))
|
||||||
.FirstOrDefault(jt => jt["role"].ToString() == role)?["general"];
|
.FirstOrDefault(jt => jt["role"].ToString() == role)?["general"];
|
||||||
if (general == null)
|
if (general == null)
|
||||||
{
|
{
|
||||||
@ -267,12 +268,12 @@ Assists: {general["assists"]} Ban: {general["banRate"]}%
|
|||||||
}
|
}
|
||||||
var cachedChamp = new CachedChampion { AddedAt = DateTime.Now, ImageStream = img.ToStream(System.Drawing.Imaging.ImageFormat.Png), Name = name.ToLower() + "_" + resolvedRole };
|
var cachedChamp = new CachedChampion { AddedAt = DateTime.Now, ImageStream = img.ToStream(System.Drawing.Imaging.ImageFormat.Png), Name = name.ToLower() + "_" + resolvedRole };
|
||||||
CachedChampionImages.Add(cachedChamp.Name, cachedChamp);
|
CachedChampionImages.Add(cachedChamp.Name, cachedChamp);
|
||||||
await e.Channel.SendFile(data["title"] + "_stats.png", cachedChamp.ImageStream);
|
await e.Channel.SendFile(data["title"] + "_stats.png", cachedChamp.ImageStream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex);
|
Console.WriteLine(ex);
|
||||||
await e.Channel.SendMessage("💢 Failed retreiving data for that champion.");
|
await e.Channel.SendMessage("💢 Failed retreiving data for that champion.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -290,7 +291,8 @@ Assists: {general["assists"]} Ban: {general["banRate"]}%
|
|||||||
.SearchHelper
|
.SearchHelper
|
||||||
.GetResponseStringAsync($"http://api.champion.gg/stats/champs/mostBanned?" +
|
.GetResponseStringAsync($"http://api.champion.gg/stats/champs/mostBanned?" +
|
||||||
$"api_key={NadekoBot.Creds.LOLAPIKey}&page=1&" +
|
$"api_key={NadekoBot.Creds.LOLAPIKey}&page=1&" +
|
||||||
$"limit={showCount}"))["data"] as JArray;
|
$"limit={showCount}")
|
||||||
|
.ConfigureAwait(false))["data"] as JArray;
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine($"**Showing {showCount} top banned champions.**");
|
sb.AppendLine($"**Showing {showCount} top banned champions.**");
|
||||||
@ -303,11 +305,11 @@ Assists: {general["assists"]} Ban: {general["banRate"]}%
|
|||||||
//sb.AppendLine($" ({data[i]["general"]["banRate"]}%)");
|
//sb.AppendLine($" ({data[i]["general"]["banRate"]}%)");
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience.");
|
await e.Channel.SendMessage($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
Tuple<bool, string> data;
|
Tuple<bool, string> data;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
data = await GetStreamStatus(stream);
|
data = await GetStreamStatus(stream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
msg += $"\n`Here is the Link:`【 http://www.beam.pro/{stream.Username}/ 】";
|
msg += $"\n`Here is the Link:`【 http://www.beam.pro/{stream.Username}/ 】";
|
||||||
else if (stream.Type == StreamNotificationConfig.StreamType.YoutubeGaming)
|
else if (stream.Type == StreamNotificationConfig.StreamType.YoutubeGaming)
|
||||||
msg += $"\n`Here is the Link:`【 not implemented yet - {stream.Username} 】";
|
msg += $"\n`Here is the Link:`【 not implemented yet - {stream.Username} 】";
|
||||||
await channel.SendMessage(msg);
|
await channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
var hitboxUrl = $"https://api.hitbox.tv/media/status/{stream.Username}";
|
var hitboxUrl = $"https://api.hitbox.tv/media/status/{stream.Username}";
|
||||||
if (cachedStatuses.TryGetValue(hitboxUrl, out result))
|
if (cachedStatuses.TryGetValue(hitboxUrl, out result))
|
||||||
return result;
|
return result;
|
||||||
response = await SearchHelper.GetResponseStringAsync(hitboxUrl);
|
response = await SearchHelper.GetResponseStringAsync(hitboxUrl).ConfigureAwait(false);
|
||||||
data = JObject.Parse(response);
|
data = JObject.Parse(response);
|
||||||
isLive = data["media_is_live"].ToString() == "1";
|
isLive = data["media_is_live"].ToString() == "1";
|
||||||
result = new Tuple<bool, string>(isLive, data["media_views"].ToString());
|
result = new Tuple<bool, string>(isLive, data["media_views"].ToString());
|
||||||
@ -95,7 +95,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
var twitchUrl = $"https://api.twitch.tv/kraken/streams/{Uri.EscapeUriString(stream.Username)}";
|
var twitchUrl = $"https://api.twitch.tv/kraken/streams/{Uri.EscapeUriString(stream.Username)}";
|
||||||
if (cachedStatuses.TryGetValue(twitchUrl, out result))
|
if (cachedStatuses.TryGetValue(twitchUrl, out result))
|
||||||
return result;
|
return result;
|
||||||
response = await SearchHelper.GetResponseStringAsync(twitchUrl);
|
response = await SearchHelper.GetResponseStringAsync(twitchUrl).ConfigureAwait(false);
|
||||||
data = JObject.Parse(response);
|
data = JObject.Parse(response);
|
||||||
isLive = !string.IsNullOrWhiteSpace(data["stream"].ToString());
|
isLive = !string.IsNullOrWhiteSpace(data["stream"].ToString());
|
||||||
result = new Tuple<bool, string>(isLive, isLive ? data["stream"]["viewers"].ToString() : "0");
|
result = new Tuple<bool, string>(isLive, isLive ? data["stream"]["viewers"].ToString() : "0");
|
||||||
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
var beamUrl = $"https://beam.pro/api/v1/channels/{stream.Username}";
|
var beamUrl = $"https://beam.pro/api/v1/channels/{stream.Username}";
|
||||||
if (cachedStatuses.TryGetValue(beamUrl, out result))
|
if (cachedStatuses.TryGetValue(beamUrl, out result))
|
||||||
return result;
|
return result;
|
||||||
response = await SearchHelper.GetResponseStringAsync(beamUrl);
|
response = await SearchHelper.GetResponseStringAsync(beamUrl).ConfigureAwait(false);
|
||||||
data = JObject.Parse(response);
|
data = JObject.Parse(response);
|
||||||
isLive = data["online"].ToObject<bool>() == true;
|
isLive = data["online"].ToObject<bool>() == true;
|
||||||
result = new Tuple<bool, string>(isLive, data["viewersCurrent"].ToString());
|
result = new Tuple<bool, string>(isLive, data["viewersCurrent"].ToString());
|
||||||
@ -162,13 +162,13 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
snc.Username.ToLower().Trim() == username);
|
snc.Username.ToLower().Trim() == username);
|
||||||
if (toRemove == null)
|
if (toRemove == null)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger: No such stream.");
|
await e.Channel.SendMessage(":anger: No such stream.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.ObservingStreams.Remove(toRemove);
|
config.ObservingStreams.Remove(toRemove);
|
||||||
ConfigHandler.SaveConfig();
|
ConfigHandler.SaveConfig();
|
||||||
await e.Channel.SendMessage($":ok: Removed `{toRemove.Username}`'s stream from notifications.");
|
await e.Channel.SendMessage($":ok: Removed `{toRemove.Username}`'s stream from notifications.").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "liststreams")
|
cgb.CreateCommand(Module.Prefix + "liststreams")
|
||||||
@ -187,7 +187,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
|
|
||||||
if (streamsArray.Length == 0)
|
if (streamsArray.Length == 0)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("You are not following any streams on this server.");
|
await e.Channel.SendMessage("You are not following any streams on this server.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
return "";
|
return "";
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await e.Channel.SendMessage($"You are following **{streamsArray.Length}** streams on this server.\n\n" + text);
|
await e.Channel.SendMessage($"You are following **{streamsArray.Length}** streams on this server.\n\n" + text).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,17 +224,17 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
var exists = config.ObservingStreams.Contains(stream);
|
var exists = config.ObservingStreams.Contains(stream);
|
||||||
if (exists)
|
if (exists)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger: I am already notifying that stream on this channel.");
|
await e.Channel.SendMessage(":anger: I am already notifying that stream on this channel.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Tuple<bool, string> data;
|
Tuple<bool, string> data;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
data = await GetStreamStatus(stream);
|
data = await GetStreamStatus(stream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(":anger: Stream probably doesn't exist.");
|
await e.Channel.SendMessage(":anger: Stream probably doesn't exist.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var msg = $"Stream is currently **{(data.Item1 ? "ONLINE" : "OFFLINE")}** with **{data.Item2}** viewers";
|
var msg = $"Stream is currently **{(data.Item1 ? "ONLINE" : "OFFLINE")}** with **{data.Item2}** viewers";
|
||||||
@ -250,7 +250,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
|||||||
stream.LastStatus = data.Item1;
|
stream.LastStatus = data.Item1;
|
||||||
if (!exists)
|
if (!exists)
|
||||||
msg = $":ok: I will notify this channel when status changes.\n{msg}";
|
msg = $":ok: I will notify this channel when status changes.\n{msg}";
|
||||||
await e.Channel.SendMessage(msg);
|
await e.Channel.SendMessage(msg).ConfigureAwait(false);
|
||||||
config.ObservingStreams.Add(stream);
|
config.ObservingStreams.Add(stream);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
{
|
{
|
||||||
var city = e.GetArg("city").Replace(" ", "");
|
var city = e.GetArg("city").Replace(" ", "");
|
||||||
var country = e.GetArg("country").Replace(" ", "");
|
var country = e.GetArg("country").Replace(" ", "");
|
||||||
var response = await SearchHelper.GetResponseStringAsync($"http://api.lawlypopzz.xyz/nadekobot/weather/?city={city}&country={country}");
|
var response = await SearchHelper.GetResponseStringAsync($"http://api.lawlypopzz.xyz/nadekobot/weather/?city={city}&country={country}").ConfigureAwait(false);
|
||||||
|
|
||||||
var obj = JObject.Parse(response)["weather"];
|
var obj = JObject.Parse(response)["weather"];
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
📏 **Lat,Long:** ({obj["latitude"]}, {obj["longitude"]}) ☁ **Condition:** {obj["condition"]}
|
📏 **Lat,Long:** ({obj["latitude"]}, {obj["longitude"]}) ☁ **Condition:** {obj["condition"]}
|
||||||
😓 **Humidity:** {obj["humidity"]}% 💨 **Wind Speed:** {obj["windspeedk"]}km/h / {obj["windspeedm"]}mph
|
😓 **Humidity:** {obj["humidity"]}% 💨 **Wind Speed:** {obj["windspeedk"]}km/h / {obj["windspeedm"]}mph
|
||||||
🔆 **Temperature:** {obj["centigrade"]}°C / {obj["fahrenheit"]}°F 🔆 **Feels like:** {obj["feelscentigrade"]}°C / {obj["feelsfahrenheit"]}°F
|
🔆 **Temperature:** {obj["centigrade"]}°C / {obj["fahrenheit"]}°F 🔆 **Feels like:** {obj["feelscentigrade"]}°C / {obj["feelsfahrenheit"]}°F
|
||||||
🌄 **Sunrise:** {obj["sunrise"]} 🌇 **Sunset:** {obj["sunset"]}");
|
🌄 **Sunrise:** {obj["sunrise"]} 🌇 **Sunset:** {obj["sunset"]}").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "yt")
|
cgb.CreateCommand(Prefix + "yt")
|
||||||
@ -65,10 +65,10 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Description("Searches youtubes and shows the first result")
|
.Description("Searches youtubes and shows the first result")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false))) return;
|
||||||
|
|
||||||
var shortUrl = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query")));
|
var shortUrl = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query")).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage(shortUrl);
|
await e.Channel.SendMessage(shortUrl).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "ani")
|
cgb.CreateCommand(Prefix + "ani")
|
||||||
@ -77,19 +77,19 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Description("Queries anilist for an anime and shows the first result.")
|
.Description("Queries anilist for an anime and shows the first result.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false))) return;
|
||||||
string result;
|
string result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = (await SearchHelper.GetAnimeData(e.GetArg("query"))).ToString();
|
result = (await SearchHelper.GetAnimeData(e.GetArg("query")).ConfigureAwait(false)).ToString();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Failed to find that anime.");
|
await e.Channel.SendMessage("Failed to find that anime.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage(result.ToString());
|
await e.Channel.SendMessage(result.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "imdb")
|
cgb.CreateCommand(Prefix + "imdb")
|
||||||
@ -97,8 +97,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Description("Queries imdb for movies or series, show first result.")
|
.Description("Queries imdb for movies or series, show first result.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false))) return;
|
||||||
await e.Channel.SendIsTyping();
|
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||||
string result;
|
string result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -108,11 +108,11 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Failed to find that movie.");
|
await e.Channel.SendMessage("Failed to find that movie.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await e.Channel.SendMessage(result.ToString());
|
await e.Channel.SendMessage(result.ToString()).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "mang")
|
cgb.CreateCommand(Prefix + "mang")
|
||||||
@ -121,18 +121,18 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Description("Queries anilist for a manga and shows the first result.")
|
.Description("Queries anilist for a manga and shows the first result.")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false))) return;
|
||||||
string result;
|
string result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = (await SearchHelper.GetMangaData(e.GetArg("query"))).ToString();
|
result = (await SearchHelper.GetMangaData(e.GetArg("query")).ConfigureAwait(false)).ToString();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Failed to find that anime.");
|
await e.Channel.SendMessage("Failed to find that anime.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(result);
|
await e.Channel.SendMessage(result).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "randomcat")
|
cgb.CreateCommand(Prefix + "randomcat")
|
||||||
@ -140,7 +140,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(JObject.Parse(
|
await e.Channel.SendMessage(JObject.Parse(
|
||||||
await SearchHelper.GetResponseStringAsync("http://www.random.cat/meow"))["file"].ToString());
|
await SearchHelper.GetResponseStringAsync("http://www.random.cat/meow").ConfigureAwait(false))["file"].ToString())
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "i")
|
cgb.CreateCommand(Prefix + "i")
|
||||||
@ -153,12 +154,12 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&fields=items%2Flink&key={NadekoBot.Creds.GoogleAPIKey}";
|
var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&fields=items%2Flink&key={NadekoBot.Creds.GoogleAPIKey}";
|
||||||
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString));
|
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
||||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString());
|
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 {ex.Message}");
|
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -172,12 +173,12 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&start={ rng.Next(1, 150) }&fields=items%2Flink&key={NadekoBot.Creds.GoogleAPIKey}";
|
var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&start={ rng.Next(1, 150) }&fields=items%2Flink&key={NadekoBot.Creds.GoogleAPIKey}";
|
||||||
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString));
|
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
||||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString());
|
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 {ex.Message}");
|
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "lmgtfy")
|
cgb.CreateCommand(Prefix + "lmgtfy")
|
||||||
@ -186,7 +187,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (e.GetArg("ffs") == null || e.GetArg("ffs").Length < 1) return;
|
if (e.GetArg("ffs") == null || e.GetArg("ffs").Length < 1) return;
|
||||||
await e.Channel.SendMessage(await $"http://lmgtfy.com/?q={ Uri.EscapeUriString(e.GetArg("ffs").ToString()) }".ShortenUrl());
|
await e.Channel.SendMessage(await $"http://lmgtfy.com/?q={ Uri.EscapeUriString(e.GetArg("ffs").ToString()) }".ShortenUrl())
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "hs")
|
cgb.CreateCommand(Prefix + "hs")
|
||||||
@ -197,12 +199,13 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
var arg = e.GetArg("name");
|
var arg = e.GetArg("name");
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Please enter a card name to search for.");
|
await e.Channel.SendMessage("💢 Please enter a card name to search for.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendIsTyping();
|
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||||
var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } };
|
var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } };
|
||||||
var res = await SearchHelper.GetResponseStringAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString(arg)}", headers);
|
var res = await SearchHelper.GetResponseStringAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString(arg)}", headers)
|
||||||
|
.ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var items = JArray.Parse(res);
|
var items = JArray.Parse(res);
|
||||||
@ -214,17 +217,18 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null))
|
foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null))
|
||||||
{
|
{
|
||||||
images.Add(
|
images.Add(
|
||||||
Image.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString())));
|
Image.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString()).ConfigureAwait(false)));
|
||||||
}
|
}
|
||||||
if (items.Count > 4)
|
if (items.Count > 4)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("⚠ Found over 4 images. Showing random 4.");
|
await e.Channel.SendMessage("⚠ Found over 4 images. Showing random 4.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await e.Channel.SendFile(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png));
|
await e.Channel.SendFile(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png))
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 Error {ex.Message}");
|
await e.Channel.SendMessage($"💢 Error {ex.Message}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -247,15 +251,15 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result));
|
await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)).ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`");
|
await e.Channel.SendMessage($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Failed retrieving osu signature :\\");
|
await e.Channel.SendMessage("💢 Failed retrieving osu signature :\\").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -268,24 +272,24 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
var arg = e.GetArg("query");
|
var arg = e.GetArg("query");
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Please enter a search term.");
|
await e.Channel.SendMessage("💢 Please enter a search term.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendIsTyping();
|
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||||
var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } };
|
var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } };
|
||||||
var res = await SearchHelper.GetResponseStringAsync($"https://mashape-community-urban-dictionary.p.mashape.com/define?term={Uri.EscapeUriString(arg)}", headers);
|
var res = await SearchHelper.GetResponseStringAsync($"https://mashape-community-urban-dictionary.p.mashape.com/define?term={Uri.EscapeUriString(arg)}", headers).ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var items = JObject.Parse(res);
|
var items = JObject.Parse(res);
|
||||||
var sb = new System.Text.StringBuilder();
|
var sb = new System.Text.StringBuilder();
|
||||||
sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}");
|
sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}");
|
||||||
sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}");
|
sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}");
|
||||||
sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl()}>");
|
sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl().ConfigureAwait(false)}>");
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Failed finding a definition for that term.");
|
await e.Channel.SendMessage("💢 Failed finding a definition for that term.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// thanks to Blaubeerwald
|
// thanks to Blaubeerwald
|
||||||
@ -297,24 +301,24 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
var arg = e.GetArg("query");
|
var arg = e.GetArg("query");
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Please enter a search term.");
|
await e.Channel.SendMessage("💢 Please enter a search term.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await e.Channel.SendIsTyping();
|
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||||
var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } };
|
var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } };
|
||||||
var res = await SearchHelper.GetResponseStringAsync($"https://tagdef.p.mashape.com/one.{Uri.EscapeUriString(arg)}.json", headers);
|
var res = await SearchHelper.GetResponseStringAsync($"https://tagdef.p.mashape.com/one.{Uri.EscapeUriString(arg)}.json", headers).ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var items = JObject.Parse(res);
|
var items = JObject.Parse(res);
|
||||||
var sb = new System.Text.StringBuilder();
|
var sb = new System.Text.StringBuilder();
|
||||||
sb.AppendLine($"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString()}");
|
sb.AppendLine($"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString()}");
|
||||||
sb.AppendLine($"`Definition:` {items["defs"]["def"]["text"].ToString()}");
|
sb.AppendLine($"`Definition:` {items["defs"]["def"]["text"].ToString()}");
|
||||||
sb.Append($"`Link:` <{await items["defs"]["def"]["uri"].ToString().ShortenUrl()}>");
|
sb.Append($"`Link:` <{await items["defs"]["def"]["uri"].ToString().ShortenUrl().ConfigureAwait(false)}>");
|
||||||
await e.Channel.SendMessage(sb.ToString());
|
await e.Channel.SendMessage(sb.ToString());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("💢 Failed finidng a definition for that tag.");
|
await e.Channel.SendMessage("💢 Failed finidng a definition for that tag.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -323,17 +327,17 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var quote = NadekoBot.Config.Quotes[rng.Next(0, NadekoBot.Config.Quotes.Count)].ToString();
|
var quote = NadekoBot.Config.Quotes[rng.Next(0, NadekoBot.Config.Quotes.Count)].ToString();
|
||||||
await e.Channel.SendMessage(quote);
|
await e.Channel.SendMessage(quote).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "catfact")
|
cgb.CreateCommand(Prefix + "catfact")
|
||||||
.Description("Shows a random catfact from <http://catfacts-api.appspot.com/api/facts>")
|
.Description("Shows a random catfact from <http://catfacts-api.appspot.com/api/facts>")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var response = await SearchHelper.GetResponseStringAsync("http://catfacts-api.appspot.com/api/facts");
|
var response = await SearchHelper.GetResponseStringAsync("http://catfacts-api.appspot.com/api/facts").ConfigureAwait(false);
|
||||||
if (response == null)
|
if (response == null)
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage($"🐈 `{JObject.Parse(response)["facts"][0].ToString()}`");
|
await e.Channel.SendMessage($"🐈 `{JObject.Parse(response)["facts"][0].ToString()}`").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "yomama")
|
cgb.CreateCommand(Prefix + "yomama")
|
||||||
@ -341,8 +345,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Description("Shows a random joke from <http://api.yomomma.info/>")
|
.Description("Shows a random joke from <http://api.yomomma.info/>")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var response = await SearchHelper.GetResponseStringAsync("http://api.yomomma.info/");
|
var response = await SearchHelper.GetResponseStringAsync("http://api.yomomma.info/").ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆");
|
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "randjoke")
|
cgb.CreateCommand(Prefix + "randjoke")
|
||||||
@ -350,8 +354,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Description("Shows a random joke from <http://tambal.azurewebsites.net/joke/random>")
|
.Description("Shows a random joke from <http://tambal.azurewebsites.net/joke/random>")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var response = await SearchHelper.GetResponseStringAsync("http://tambal.azurewebsites.net/joke/random");
|
var response = await SearchHelper.GetResponseStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆");
|
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "chucknorris")
|
cgb.CreateCommand(Prefix + "chucknorris")
|
||||||
@ -359,8 +363,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
.Description("Shows a random chucknorris joke from <http://tambal.azurewebsites.net/joke/random>")
|
.Description("Shows a random chucknorris joke from <http://tambal.azurewebsites.net/joke/random>")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var response = await SearchHelper.GetResponseStringAsync("http://api.icndb.com/jokes/random/");
|
var response = await SearchHelper.GetResponseStringAsync("http://api.icndb.com/jokes/random/").ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["value"]["joke"].ToString() + "` 😆");
|
await e.Channel.SendMessage("`" + JObject.Parse(response)["value"]["joke"].ToString() + "` 😆").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "mi")
|
cgb.CreateCommand(Prefix + "mi")
|
||||||
@ -371,7 +375,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
var magicItems = JsonConvert.DeserializeObject<List<MagicItem>>(File.ReadAllText("data/magicitems.json"));
|
var magicItems = JsonConvert.DeserializeObject<List<MagicItem>>(File.ReadAllText("data/magicitems.json"));
|
||||||
var item = magicItems[rng.Next(0, magicItems.Count)].ToString();
|
var item = magicItems[rng.Next(0, magicItems.Count)].ToString();
|
||||||
|
|
||||||
await e.Channel.SendMessage(item);
|
await e.Channel.SendMessage(item).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "revav")
|
cgb.CreateCommand(Prefix + "revav")
|
||||||
@ -388,7 +392,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
|
|
||||||
if (usr == null || string.IsNullOrWhiteSpace(usr.AvatarUrl))
|
if (usr == null || string.IsNullOrWhiteSpace(usr.AvatarUrl))
|
||||||
return;
|
return;
|
||||||
await e.Channel.SendMessage($"https://images.google.com/searchbyimage?image_url={usr.AvatarUrl}");
|
await e.Channel.SendMessage($"https://images.google.com/searchbyimage?image_url={usr.AvatarUrl}").ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -23,16 +23,16 @@ namespace NadekoBot.Modules.Translator
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Channel.SendIsTyping();
|
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||||
string from = e.GetArg("langs").ToLowerInvariant().Split('>')[0];
|
string from = e.GetArg("langs").ToLowerInvariant().Split('>')[0];
|
||||||
string to = e.GetArg("langs").ToLowerInvariant().Split('>')[1];
|
string to = e.GetArg("langs").ToLowerInvariant().Split('>')[1];
|
||||||
|
|
||||||
string translation = t.Translate(e.GetArg("text"), from, to);
|
string translation = t.Translate(e.GetArg("text"), from, to);
|
||||||
await e.Channel.SendMessage(translation);
|
await e.Channel.SendMessage(translation).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Bad input format, or sth went wrong...");
|
await e.Channel.SendMessage("Bad input format, or sth went wrong...").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -38,11 +38,11 @@ namespace NadekoBot.Modules.Translator
|
|||||||
ret += " " + key + ";";
|
ret += " " + key + ";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await e.Channel.SendMessage(ret);
|
await e.Channel.SendMessage(ret).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage("Bad input format, or sth went wrong...");
|
await e.Channel.SendMessage("Bad input format, or sth went wrong...").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Trello
|
|||||||
|
|
||||||
foreach (var a in cur5ActionsArray.Where(ca => !last5ActionIDs.Contains(ca.Id)))
|
foreach (var a in cur5ActionsArray.Where(ca => !last5ActionIDs.Contains(ca.Id)))
|
||||||
{
|
{
|
||||||
await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString());
|
await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
last5ActionIDs.Clear();
|
last5ActionIDs.Clear();
|
||||||
last5ActionIDs.AddRange(cur5ActionsArray.Select(a => a.Id));
|
last5ActionIDs.AddRange(cur5ActionsArray.Select(a => a.Id));
|
||||||
@ -74,10 +74,11 @@ namespace NadekoBot.Modules.Trello
|
|||||||
.Parameter("code", Discord.Commands.ParameterType.Required)
|
.Parameter("code", Discord.Commands.ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
if (!NadekoBot.IsOwner(e.User.Id) || NadekoBot.IsBot) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await (await client.GetInvite(e.GetArg("code"))).Accept();
|
await (await client.GetInvite(e.GetArg("code")).ConfigureAwait(false)).Accept()
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -117,7 +118,7 @@ namespace NadekoBot.Modules.Trello
|
|||||||
t.Stop();
|
t.Stop();
|
||||||
bound = null;
|
bound = null;
|
||||||
board = null;
|
board = null;
|
||||||
await e.Channel.SendMessage("Successfully unbound trello from this channel.");
|
await e.Channel.SendMessage("Successfully unbound trello from this channel.").ConfigureAwait(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -128,7 +129,8 @@ namespace NadekoBot.Modules.Trello
|
|||||||
{
|
{
|
||||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||||
if (bound == null || board == null || bound != e.Channel) return;
|
if (bound == null || board == null || bound != e.Channel) return;
|
||||||
await e.Channel.SendMessage("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")));
|
await e.Channel.SendMessage("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")))
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("cards")
|
cgb.CreateCommand("cards")
|
||||||
@ -149,9 +151,11 @@ namespace NadekoBot.Modules.Trello
|
|||||||
|
|
||||||
|
|
||||||
if (list != null)
|
if (list != null)
|
||||||
await e.Channel.SendMessage("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**")));
|
await e.Channel.SendMessage("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**")))
|
||||||
|
.ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await e.Channel.SendMessage("No such list.");
|
await e.Channel.SendMessage("No such list.")
|
||||||
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ namespace NadekoBot
|
|||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(e.Exception.Message);
|
await e.Channel.SendMessage(e.Exception.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@ -192,10 +192,10 @@ namespace NadekoBot
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(Creds.Token))
|
if (string.IsNullOrWhiteSpace(Creds.Token))
|
||||||
await Client.Connect(Creds.Username, Creds.Password);
|
await Client.Connect(Creds.Username, Creds.Password).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await Client.Connect(Creds.Token);
|
await Client.Connect(Creds.Token).ConfigureAwait(false);
|
||||||
IsBot = true;
|
IsBot = true;
|
||||||
}
|
}
|
||||||
Console.WriteLine(NadekoBot.Client.CurrentUser.Id);
|
Console.WriteLine(NadekoBot.Client.CurrentUser.Id);
|
||||||
@ -211,14 +211,14 @@ namespace NadekoBot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//await Task.Delay(90000);
|
await Task.Delay(90000).ConfigureAwait(false);
|
||||||
Console.WriteLine("-----------------");
|
Console.WriteLine("-----------------");
|
||||||
Console.WriteLine(await NadekoStats.Instance.GetStats());
|
Console.WriteLine(await NadekoStats.Instance.GetStats().ConfigureAwait(false));
|
||||||
Console.WriteLine("-----------------");
|
Console.WriteLine("-----------------");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OwnerPrivateChannel = await Client.CreatePrivateChannel(Creds.OwnerIds[0]);
|
OwnerPrivateChannel = await Client.CreatePrivateChannel(Creds.OwnerIds[0]).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -245,7 +245,7 @@ namespace NadekoBot
|
|||||||
public async Task SendMessageToOwner(string message)
|
public async Task SendMessageToOwner(string message)
|
||||||
{
|
{
|
||||||
if (Config.ForwardMessages && OwnerPrivateChannel != null)
|
if (Config.ForwardMessages && OwnerPrivateChannel != null)
|
||||||
await OwnerPrivateChannel.SendMessage(message);
|
await OwnerPrivateChannel.SendMessage(message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool repliedRecently = false;
|
private static bool repliedRecently = false;
|
||||||
@ -262,29 +262,29 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await (await Client.GetInvite(e.Message.Text)).Accept();
|
await (await Client.GetInvite(e.Message.Text).ConfigureAwait(false)).Accept().ConfigureAwait(false);
|
||||||
await e.Channel.SendMessage("I got in!");
|
await e.Channel.SendMessage("I got in!").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (e.User.Id == 109338686889476096)
|
if (e.User.Id == 109338686889476096)
|
||||||
{ //carbonitex invite
|
{ //carbonitex invite
|
||||||
await e.Channel.SendMessage("Failed to join the server.");
|
await e.Channel.SendMessage("Failed to join the server.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannel != null)
|
if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannel != null)
|
||||||
await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```");
|
await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false);
|
||||||
|
|
||||||
if (repliedRecently) return;
|
if (repliedRecently) return;
|
||||||
|
|
||||||
repliedRecently = true;
|
repliedRecently = true;
|
||||||
if (e.Message.RawText != "-h")
|
if (e.Message.RawText != "-h")
|
||||||
await e.Channel.SendMessage(HelpCommand.DMHelpString);
|
await e.Channel.SendMessage(HelpCommand.DMHelpString).ConfigureAwait(false);
|
||||||
await Task.Delay(2000);
|
await Task.Delay(2000).ConfigureAwait(false);
|
||||||
repliedRecently = false;
|
repliedRecently = false;
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
@ -471,7 +471,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
Loading…
Reference in New Issue
Block a user