ConfigureAwait ALL THE THINGS
This commit is contained in:
parent
f8d52e2307
commit
113c2b43bd
@ -1,24 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Cryptography;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
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
|
||||
{
|
||||
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 count = 0;
|
||||
for (var i = 0; i < letters.Length; i++) {
|
||||
for (var i = 0; i < letters.Length; i++)
|
||||
{
|
||||
if (letters[i] == ' ')
|
||||
continue;
|
||||
|
||||
@ -32,9 +35,10 @@ namespace NadekoBot.Extensions {
|
||||
if (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)
|
||||
throw new ArgumentOutOfRangeException(nameof(num), "TrimTo argument cannot be less than 0");
|
||||
if (num == 0)
|
||||
@ -52,7 +56,8 @@ namespace NadekoBot.Extensions {
|
||||
/// <param name="num"></param>
|
||||
/// <param name="es"></param>
|
||||
/// <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)
|
||||
throw new ArgumentNullException(nameof(str));
|
||||
if (num == null)
|
||||
@ -66,8 +71,8 @@ namespace NadekoBot.Extensions {
|
||||
/// <param name="e">EventArg</param>
|
||||
/// <param name="message">Message to be sent</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Message> Send(this CommandEventArgs e, string message)
|
||||
=> await e.Channel.SendMessage(message);
|
||||
public static async Task<Message> Send(this CommandEventArgs e, string message)
|
||||
=> await e.Channel.SendMessage(message).ConfigureAwait(false);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message to the channel from which MessageEventArg came.
|
||||
@ -79,7 +84,7 @@ namespace NadekoBot.Extensions {
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
return;
|
||||
await e.Channel.SendMessage(message);
|
||||
await e.Channel.SendMessage(message).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -90,7 +95,7 @@ namespace NadekoBot.Extensions {
|
||||
/// <returns></returns>
|
||||
public static async Task Send(this Channel c, string message)
|
||||
{
|
||||
await c.SendMessage(message);
|
||||
await c.SendMessage(message).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -101,7 +106,7 @@ namespace NadekoBot.Extensions {
|
||||
/// <returns></returns>
|
||||
public static async Task Send(this User u, string message)
|
||||
{
|
||||
await u.SendMessage(message);
|
||||
await u.SendMessage(message).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,7 +117,7 @@ namespace NadekoBot.Extensions {
|
||||
/// <returns></returns>
|
||||
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>
|
||||
@ -123,7 +128,7 @@ namespace NadekoBot.Extensions {
|
||||
/// <returns></returns>
|
||||
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>
|
||||
@ -154,7 +159,7 @@ namespace NadekoBot.Extensions {
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="source"></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>
|
||||
/// Gets the program runtime
|
||||
@ -167,40 +172,49 @@ namespace NadekoBot.Extensions {
|
||||
public static string Matrix(this string s)
|
||||
=>
|
||||
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) {
|
||||
foreach (var element in source) {
|
||||
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
|
||||
{
|
||||
foreach (var element in source)
|
||||
{
|
||||
action(element);
|
||||
}
|
||||
}
|
||||
|
||||
//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 m = t.Length;
|
||||
var d = new int[n + 1, m + 1];
|
||||
|
||||
// Step 1
|
||||
if (n == 0) {
|
||||
if (n == 0)
|
||||
{
|
||||
return m;
|
||||
}
|
||||
|
||||
if (m == 0) {
|
||||
if (m == 0)
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
// 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
|
||||
for (var i = 1; i <= n; i++) {
|
||||
for (var i = 1; i <= n; i++)
|
||||
{
|
||||
//Step 4
|
||||
for (var j = 1; j <= m; j++) {
|
||||
for (var j = 1; j <= m; j++)
|
||||
{
|
||||
// Step 5
|
||||
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 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)
|
||||
format = System.Drawing.Imaging.ImageFormat.Jpeg;
|
||||
var stream = new MemoryStream();
|
||||
@ -237,22 +252,26 @@ namespace NadekoBot.Extensions {
|
||||
/// </summary>
|
||||
/// <param name="images">The Images you want to merge.</param>
|
||||
/// <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();
|
||||
if (!imageArray.Any()) return null;
|
||||
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 r = new Random();
|
||||
var offsetx = 0;
|
||||
foreach (var img in imageArray) {
|
||||
foreach (var img in imageArray)
|
||||
{
|
||||
var bm = new Bitmap(img);
|
||||
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 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));
|
||||
}
|
||||
}
|
||||
offsetx += img.Width/reverseScaleFactor;
|
||||
offsetx += img.Width / reverseScaleFactor;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
@ -264,6 +283,6 @@ namespace NadekoBot.Extensions {
|
||||
/// <param name="reverseScaleFactor"></param>
|
||||
/// <returns>Merged bitmap</returns>
|
||||
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,
|
||||
Value = amount,
|
||||
});
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
if (silent)
|
||||
return;
|
||||
@ -26,7 +26,7 @@ namespace NadekoBot.Classes
|
||||
{
|
||||
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)
|
||||
|
@ -29,7 +29,7 @@ namespace NadekoBot
|
||||
public int VoiceChannelsCount { get; private set; } = 0;
|
||||
|
||||
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() { }
|
||||
|
||||
@ -50,25 +50,25 @@ namespace NadekoBot
|
||||
TextChannelsCount = channelsArray.Count(c => c.Type == ChannelType.Text);
|
||||
VoiceChannelsCount = channelsArray.Count() - TextChannelsCount;
|
||||
|
||||
NadekoBot.Client.JoinedServer += async (s, e) =>
|
||||
NadekoBot.Client.JoinedServer += (s, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ServerCount++;
|
||||
TextChannelsCount += e.Server.TextChannels.Count();
|
||||
VoiceChannelsCount += e.Server.VoiceChannels.Count();
|
||||
await SendUpdateToCarbon().ConfigureAwait(false);
|
||||
//await SendUpdateToCarbon().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
NadekoBot.Client.LeftServer += async (s, e) =>
|
||||
NadekoBot.Client.LeftServer += (s, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ServerCount--;
|
||||
TextChannelsCount -= e.Server.TextChannels.Count();
|
||||
VoiceChannelsCount -= e.Server.VoiceChannels.Count();
|
||||
await SendUpdateToCarbon().ConfigureAwait(false);
|
||||
//await SendUpdateToCarbon().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
@ -98,27 +98,26 @@ namespace NadekoBot
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
carbonStatusTimer.Elapsed += async (s, e) => await SendUpdateToCarbon().ConfigureAwait(false);
|
||||
carbonStatusTimer.Start();
|
||||
}
|
||||
|
||||
HttpClient carbonClient = new HttpClient();
|
||||
private async Task SendUpdateToCarbon()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.CarbonKey))
|
||||
return;
|
||||
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() },
|
||||
{ "key", NadekoBot.Creds.CarbonKey }
|
||||
}))
|
||||
{
|
||||
content.Headers.Clear();
|
||||
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||
{
|
||||
content.Headers.Clear();
|
||||
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)
|
||||
{
|
||||
@ -165,7 +164,7 @@ namespace NadekoBot
|
||||
{
|
||||
if (statsStopwatch.Elapsed.Seconds < 4 &&
|
||||
!string.IsNullOrWhiteSpace(statsCache)) return statsCache;
|
||||
await LoadStats();
|
||||
await LoadStats().ConfigureAwait(false);
|
||||
statsStopwatch.Restart();
|
||||
return statsCache;
|
||||
}
|
||||
@ -174,12 +173,13 @@ namespace NadekoBot
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
await Task.Delay(new TimeSpan(0, 30, 0));
|
||||
await Task.Delay(new TimeSpan(0, 30, 0)).ConfigureAwait(false);
|
||||
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
|
||||
.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();
|
||||
|
||||
Classes.DbHandler.Instance.InsertData(new DataModels.Stats
|
||||
@ -223,7 +223,7 @@ namespace NadekoBot
|
||||
{
|
||||
Console.WriteLine("Error in ran command DB write.");
|
||||
}
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -41,15 +41,15 @@ namespace NadekoBot.Classes
|
||||
httpClient.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value);
|
||||
}
|
||||
}
|
||||
return await httpClient.GetStreamAsync(url);
|
||||
return await httpClient.GetStreamAsync(url).ConfigureAwait(false);
|
||||
case RequestHttpMethod.Post:
|
||||
FormUrlEncodedContent formContent = null;
|
||||
if (headers != null)
|
||||
{
|
||||
formContent = new FormUrlEncodedContent(headers);
|
||||
}
|
||||
var message = await httpClient.PostAsync(url, formContent);
|
||||
return await message.Content.ReadAsStreamAsync();
|
||||
var message = await httpClient.PostAsync(url, formContent).ConfigureAwait(false);
|
||||
return await message.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||
default:
|
||||
throw new NotImplementedException("That type of request is unsupported.");
|
||||
}
|
||||
@ -60,9 +60,9 @@ namespace NadekoBot.Classes
|
||||
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))
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
|
||||
await RefreshAnilistToken();
|
||||
await RefreshAnilistToken().ConfigureAwait(false);
|
||||
|
||||
var link = "http://anilist.co/api/anime/search/" + Uri.EscapeUriString(query);
|
||||
var smallContent = "";
|
||||
@ -85,7 +85,7 @@ namespace NadekoBot.Classes
|
||||
rq.AddParameter("access_token", token);
|
||||
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)
|
||||
@ -93,7 +93,7 @@ namespace NadekoBot.Classes
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
|
||||
await RefreshAnilistToken();
|
||||
await RefreshAnilistToken().ConfigureAwait(false);
|
||||
|
||||
var link = "http://anilist.co/api/anime/search/" + Uri.EscapeUriString(query);
|
||||
var smallContent = "";
|
||||
@ -107,7 +107,7 @@ namespace NadekoBot.Classes
|
||||
rq.AddParameter("access_token", token);
|
||||
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()
|
||||
@ -123,8 +123,10 @@ namespace NadekoBot.Classes
|
||||
{"client_id", "kwoth-w0ki9"},
|
||||
{"client_secret", "Qd6j4FIAi1ZK6Pc7N7V4Z"},
|
||||
};
|
||||
var content =
|
||||
await GetResponseStringAsync("http://anilist.co/api/auth/access_token", headers, RequestHttpMethod.Post);
|
||||
var content = await GetResponseStringAsync(
|
||||
"http://anilist.co/api/auth/access_token",
|
||||
headers,
|
||||
RequestHttpMethod.Post).ConfigureAwait(false);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -151,12 +153,11 @@ namespace NadekoBot.Classes
|
||||
{
|
||||
return $"http://www.youtube.com?v={match.Groups["id"].Value}";
|
||||
}
|
||||
var response =
|
||||
await
|
||||
GetResponseStringAsync($"https://www.googleapis.com/youtube/v3/search?" +
|
||||
$"part=snippet&maxResults=1" +
|
||||
$"&q={Uri.EscapeDataString(keywords)}" +
|
||||
$"&key={NadekoBot.Creds.GoogleAPIKey}");
|
||||
var response = await GetResponseStringAsync(
|
||||
$"https://www.googleapis.com/youtube/v3/search?" +
|
||||
$"part=snippet&maxResults=1" +
|
||||
$"&q={Uri.EscapeDataString(keywords)}" +
|
||||
$"&key={NadekoBot.Creds.GoogleAPIKey}").ConfigureAwait(false);
|
||||
dynamic obj = JObject.Parse(response);
|
||||
return "http://www.youtube.com/watch?v=" + obj.items[0].id.videoId.ToString();
|
||||
}
|
||||
@ -171,7 +172,7 @@ namespace NadekoBot.Classes
|
||||
$"&q={Uri.EscapeDataString(query)}" +
|
||||
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
||||
|
||||
var response = await GetResponseStringAsync(link);
|
||||
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
||||
dynamic obj = JObject.Parse(response);
|
||||
|
||||
return obj.items[0].id.playlistId.ToString();
|
||||
@ -191,8 +192,8 @@ namespace NadekoBot.Classes
|
||||
$"&playlistId={playlist}" +
|
||||
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
||||
|
||||
var response = await GetResponseStringAsync(link);
|
||||
var obj = await Task.Run(() => JObject.Parse(response));
|
||||
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
||||
var obj = await Task.Run(() => JObject.Parse(response)).ConfigureAwait(false);
|
||||
|
||||
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))
|
||||
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>.*?)\"");
|
||||
|
||||
return $"http://danbooru.donmai.us" +
|
||||
@ -221,7 +222,7 @@ namespace NadekoBot.Classes
|
||||
{
|
||||
var url =
|
||||
$"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>.*?)\"");
|
||||
if (matches.Count == 0)
|
||||
throw new FileNotFoundException();
|
||||
@ -235,7 +236,7 @@ namespace NadekoBot.Classes
|
||||
var rng = new Random();
|
||||
var url =
|
||||
$"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>.*?)\"");
|
||||
if (matches.Count == 0)
|
||||
throw new FileNotFoundException();
|
||||
@ -248,7 +249,7 @@ namespace NadekoBot.Classes
|
||||
var rng = new Random();
|
||||
var url =
|
||||
$"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>.*?)\"");
|
||||
if (matches.Count == 0)
|
||||
throw new FileNotFoundException();
|
||||
@ -261,7 +262,7 @@ namespace NadekoBot.Classes
|
||||
{
|
||||
var rng = new Random();
|
||||
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>.*?)\"");
|
||||
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
||||
}
|
||||
@ -277,19 +278,19 @@ namespace NadekoBot.Classes
|
||||
httpWebRequest.ContentType = "application/json";
|
||||
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 + "\"}";
|
||||
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";
|
||||
var responseStream = httpResponse.GetResponseStream();
|
||||
if (responseStream == null) return "RESPONSE_STREAM ERROR";
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -57,31 +57,31 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
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;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await usr.AddRoles(role);
|
||||
await e.Channel.SendMessage($"Successfully added role **{role.Name}** to user **{usr.Name}**");
|
||||
await usr.AddRoles(role).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Successfully added role **{role.Name}** to user **{usr.Name}**").ConfigureAwait(false);
|
||||
}
|
||||
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());
|
||||
}
|
||||
});
|
||||
@ -101,25 +101,25 @@ namespace NadekoBot.Modules.Administration
|
||||
var usr = e.Server.FindUsers(userName).FirstOrDefault();
|
||||
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;
|
||||
}
|
||||
|
||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
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;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await usr.RemoveRoles(role);
|
||||
await e.Channel.SendMessage($"Successfully removed role **{role.Name}** from user **{usr.Name}**");
|
||||
await usr.RemoveRoles(role).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Successfully removed role **{role.Name}** from user **{usr.Name}**").ConfigureAwait(false);
|
||||
}
|
||||
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;
|
||||
try
|
||||
{
|
||||
var r = await e.Server.CreateRole(e.GetArg("role_name"));
|
||||
await e.Channel.SendMessage($"Successfully created role **{r.Name}**.");
|
||||
var r = await e.Server.CreateRole(e.GetArg("role_name")).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Successfully created role **{r.Name}**.").ConfigureAwait(false);
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
await e.Channel.SendMessage("That role does not exist.");
|
||||
await e.Channel.SendMessage("That role does not exist.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
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 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 e.Channel.SendMessage($"Role {role.Name}'s color has been changed.");
|
||||
await role.Edit(color: new Color(red, green, blue)).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.").ConfigureAwait(false);
|
||||
}
|
||||
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();
|
||||
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;
|
||||
}
|
||||
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")
|
||||
@ -217,24 +217,24 @@ namespace NadekoBot.Modules.Administration
|
||||
var usr = e.Server.FindUsers(user).FirstOrDefault();
|
||||
if (usr == null)
|
||||
{
|
||||
await e.Channel.SendMessage("User not found.");
|
||||
await e.Channel.SendMessage("User not found.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(msg))
|
||||
{
|
||||
await usr.SendMessage($"**You have been BANNED from `{e.Server.Name}` server.**\n" +
|
||||
$"Reason: {msg}");
|
||||
await Task.Delay(2000); // temp solution; give time for a message to be send, fu volt
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||
}
|
||||
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
|
||||
{
|
||||
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();
|
||||
if (usr == null)
|
||||
{
|
||||
await e.Channel.SendMessage("User not found.");
|
||||
await e.Channel.SendMessage("User not found.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(msg))
|
||||
{
|
||||
await usr.SendMessage($"**You have been KICKED from `{e.Server.Name}` server.**\n" +
|
||||
$"Reason: {msg}");
|
||||
await Task.Delay(2000); // temp solution; give time for a message to be send, fu volt
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||
}
|
||||
try
|
||||
{
|
||||
await usr.Kick();
|
||||
await e.Channel.SendMessage("Kicked user " + usr.Name + " Id: " + usr.Id);
|
||||
await usr.Kick().ConfigureAwait(false);
|
||||
await e.Channel.SendMessage("Kicked user " + usr.Name + " Id: " + usr.Id).ConfigureAwait(false);
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (!e.Message.MentionedUsers.Any())
|
||||
@ -288,13 +288,13 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (!e.Message.MentionedUsers.Any())
|
||||
@ -314,13 +314,13 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (!e.Message.MentionedUsers.Any())
|
||||
@ -341,13 +341,13 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (!e.Message.MentionedUsers.Any())
|
||||
@ -368,13 +368,13 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault()?.Delete();
|
||||
await e.Channel.SendMessage($"Removed channel **{e.GetArg("channel_name")}**.");
|
||||
var ch = e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault();
|
||||
if (ch == null)
|
||||
return;
|
||||
await ch.Delete().ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Removed channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch
|
||||
@ -406,13 +409,13 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
if (e.User.ServerPermissions.ManageChannels)
|
||||
{
|
||||
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice);
|
||||
await e.Channel.SendMessage($"Created voice channel **{e.GetArg("channel_name")}**.");
|
||||
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Created voice channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
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();
|
||||
if (channel == null) return;
|
||||
await channel.Delete();
|
||||
await e.Channel.SendMessage($"Removed text channel **{e.GetArg("channel_name")}**.");
|
||||
await channel.Delete().ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Removed text channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text);
|
||||
await e.Channel.SendMessage($"Added text channel **{e.GetArg("channel_name")}**.");
|
||||
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"Added text channel **{e.GetArg("channel_name")}**.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
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");
|
||||
if (string.IsNullOrWhiteSpace(topic))
|
||||
return;
|
||||
await e.Channel.Edit(topic: topic);
|
||||
await e.Channel.SendMessage(":ok: **New channel topic set.**");
|
||||
await e.Channel.Edit(topic: topic).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage(":ok: **New channel topic set.**").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
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 (usr == null)
|
||||
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")
|
||||
.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")
|
||||
.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")
|
||||
.Description("Shows some basic stats for Nadeko.")
|
||||
@ -501,7 +504,7 @@ namespace NadekoBot.Modules.Administration
|
||||
.Description("Shows some basic stats for Nadeko.")
|
||||
.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")
|
||||
@ -509,8 +512,8 @@ namespace NadekoBot.Modules.Administration
|
||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||
.Do(async e =>
|
||||
{
|
||||
var heap = await Task.Run(() => NadekoStats.Instance.Heap());
|
||||
await e.Channel.SendMessage($"`Heap Size:` {heap}");
|
||||
var heap = await Task.Run(() => NadekoStats.Instance.Heap()).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($"`Heap Size:` {heap}").ConfigureAwait(false);
|
||||
});
|
||||
cgb.CreateCommand(Prefix + "prune")
|
||||
.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)
|
||||
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 Task.Delay(100);
|
||||
await msg.Delete().ConfigureAwait(false);
|
||||
await Task.Delay(100).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
|
||||
@ -536,8 +539,8 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
if (NadekoBot.IsOwner(e.User.Id))
|
||||
{
|
||||
await e.Channel.SendMessage("`Shutting down.`");
|
||||
await Task.Delay(2000);
|
||||
await e.Channel.SendMessage("`Shutting down.`").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
});
|
||||
@ -556,18 +559,18 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
await m.Delete();
|
||||
await m.Delete().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
await Task.Delay(200);
|
||||
await Task.Delay(200).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "newname")
|
||||
@ -578,7 +581,7 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
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")
|
||||
@ -591,13 +594,13 @@ namespace NadekoBot.Modules.Administration
|
||||
return;
|
||||
// Gather user provided URL.
|
||||
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);
|
||||
// Save the image to disk.
|
||||
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.
|
||||
await e.Channel.SendMessage("New avatar set.");
|
||||
await e.Channel.SendMessage("New avatar set.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "setgame")
|
||||
@ -620,7 +623,7 @@ namespace NadekoBot.Modules.Administration
|
||||
output += p.Name + ": " + p.GetValue(e.User.ServerPermissions, null).ToString() + "\n";
|
||||
}
|
||||
output += "```";
|
||||
await e.User.SendMessage(output);
|
||||
await e.User.SendMessage(output).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
Server commsServer = null;
|
||||
@ -637,10 +640,10 @@ namespace NadekoBot.Modules.Administration
|
||||
if (commsUser != null)
|
||||
{
|
||||
commsChannel = null;
|
||||
await e.Channel.SendMessage("User for comms set.");
|
||||
await e.Channel.SendMessage("User for comms set.").ConfigureAwait(false);
|
||||
}
|
||||
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")
|
||||
@ -651,9 +654,9 @@ namespace NadekoBot.Modules.Administration
|
||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
commsServer = client.FindServers(e.GetArg("server")).FirstOrDefault();
|
||||
if (commsServer != null)
|
||||
await e.Channel.SendMessage("Server for comms set.");
|
||||
await e.Channel.SendMessage("Server for comms set.").ConfigureAwait(false);
|
||||
else
|
||||
await e.Channel.SendMessage("No such server.");
|
||||
await e.Channel.SendMessage("No such server.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "commschannel")
|
||||
@ -666,10 +669,10 @@ namespace NadekoBot.Modules.Administration
|
||||
if (commsChannel != null)
|
||||
{
|
||||
commsUser = null;
|
||||
await e.Channel.SendMessage("Server for comms set.");
|
||||
await e.Channel.SendMessage("Server for comms set.").ConfigureAwait(false);
|
||||
}
|
||||
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")
|
||||
@ -679,11 +682,11 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
if (commsUser != null)
|
||||
await commsUser.SendMessage(e.GetArg("msg"));
|
||||
await commsUser.SendMessage(e.GetArg("msg")).ConfigureAwait(false);
|
||||
else if (commsChannel != null)
|
||||
await commsChannel.SendMessage(e.GetArg("msg"));
|
||||
await commsChannel.SendMessage(e.GetArg("msg")).ConfigureAwait(false);
|
||||
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")
|
||||
@ -710,12 +713,12 @@ namespace NadekoBot.Modules.Administration
|
||||
var curstr = send.Substring(0, 2000);
|
||||
await
|
||||
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.Substring(2000);
|
||||
}
|
||||
await e.Channel.Send(send);
|
||||
});
|
||||
await e.Channel.Send(send).ConfigureAwait(false);
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "parsetosql")
|
||||
@ -731,7 +734,7 @@ namespace NadekoBot.Modules.Administration
|
||||
SaveParseToDb<Request>("data/parsedata/Requests.json");
|
||||
SaveParseToDb<Stats>("data/parsedata/Stats.json");
|
||||
SaveParseToDb<TypingArticle>("data/parsedata/TypingArticles.json");
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "unstuck")
|
||||
@ -752,8 +755,8 @@ namespace NadekoBot.Modules.Administration
|
||||
var donatorsOrdered = rows.OrderByDescending(d => d.Amount);
|
||||
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
|
||||
@ -783,7 +786,7 @@ namespace NadekoBot.Modules.Administration
|
||||
e.Channel.SendMessage("Successfuly added a new donator. 👑");
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "videocall")
|
||||
@ -799,7 +802,7 @@ namespace NadekoBot.Modules.Administration
|
||||
str += new Random().Next();
|
||||
foreach (var usr in allUsrsArray)
|
||||
{
|
||||
await usr.SendMessage(str);
|
||||
await usr.SendMessage(str).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -25,7 +25,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
continue;
|
||||
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 =>
|
||||
m.RawText == GetText(e.Server, e.Channel, e.User, e.Before));
|
||||
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))
|
||||
{
|
||||
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))
|
||||
return;
|
||||
set.Add(e.Channel);
|
||||
await e.Channel.SendMessage(":ok:");
|
||||
await e.Channel.SendMessage(":ok:").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Module.Prefix + "lcsc")
|
||||
@ -103,7 +103,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
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($"`Owner:` **{server.Owner}**");
|
||||
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($"`Members:` **{server.UserCount}** `Online:` **{server.Users.Count(u => u.Status == UserStatus.Online)}** (may be incorrect)");
|
||||
sb.AppendLine($"`Roles:` **{server.Roles.Count()}**");
|
||||
@ -44,7 +44,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
sb.AppendLine($"`Features:` **{string.Join(", ", server.Features)}**");
|
||||
if (!string.IsNullOrWhiteSpace(server.SplashId))
|
||||
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")
|
||||
@ -66,7 +66,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
sb.AppendLine($"`Created At:` **{createdAt}**");
|
||||
sb.AppendLine($"`Topic:` **{ch.Topic}**");
|
||||
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")
|
||||
@ -87,8 +87,8 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
sb.AppendLine($"`Current Game:` **{(string.IsNullOrWhiteSpace(user.CurrentGame) ? "-" : user.CurrentGame)}**");
|
||||
sb.AppendLine($"`Joined At:` **{user.JoinedAt}**");
|
||||
sb.AppendLine($"`Roles:` **({user.Roles.Count()}) - {string.Join(", ", user.Roles.Select(r => r.Name))}**");
|
||||
sb.AppendLine($"`AvatarUrl:` **{await user.AvatarUrl.ShortenUrl()}**");
|
||||
await e.Channel.SendMessage(sb.ToString());
|
||||
sb.AppendLine($"`AvatarUrl:` **{await user.AvatarUrl.ShortenUrl().ConfigureAwait(false)}**");
|
||||
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);
|
||||
if (usr?.Status != UserStatus.Offline)
|
||||
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(
|
||||
$"User `{e.User.Name}` mentioned you on " +
|
||||
$"`{e.Server.Name}` server while you were offline.\n" +
|
||||
$"`Message:` {e.Message.Text}");
|
||||
$"`Message:` {e.Message.Text}").ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
Channel ch;
|
||||
if (!logs.TryGetValue(e.Server, out ch))
|
||||
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 { }
|
||||
}
|
||||
@ -63,11 +63,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (!logs.TryRemove(e.Server, out ch))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
Channel ch;
|
||||
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
||||
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 { }
|
||||
}
|
||||
@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
Channel ch;
|
||||
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
||||
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 { }
|
||||
}
|
||||
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
Channel ch;
|
||||
if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch)
|
||||
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 { }
|
||||
}
|
||||
@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (loggingPresences.TryGetValue(e.Server, out ch))
|
||||
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 { }
|
||||
@ -127,12 +127,12 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (e.Before.VoiceChannel != null && voiceChannelLog.ContainsKey(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 != 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 { }
|
||||
@ -149,7 +149,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
str += $"`New Avatar:` {e.After.AvatarUrl}";
|
||||
else
|
||||
return;
|
||||
await ch.SendMessage(str);
|
||||
await ch.SendMessage(str).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@ -167,10 +167,10 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
!specificConfig.SendPrivateMessageOnMention;
|
||||
if (specificConfig.SendPrivateMessageOnMention)
|
||||
await e.Channel.SendMessage(":ok: I will send private messages " +
|
||||
"to mentioned offline users.");
|
||||
"to mentioned offline users.").ConfigureAwait(false);
|
||||
else
|
||||
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")
|
||||
@ -189,11 +189,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (!loggingPresences.TryRemove(e.Server, out ch))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
await e.Channel.SendMessage($"**User presence notifications disabled.**");
|
||||
await e.Channel.SendMessage($"**User presence notifications disabled.**").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Module.Prefix + "voicepresence")
|
||||
@ -210,23 +210,23 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Channel throwaway;
|
||||
if (!voiceChannelLog.TryRemove(e.User.VoiceChannel, out throwaway))
|
||||
{
|
||||
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
|
||||
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
|
||||
{
|
||||
if (lastMessage != null)
|
||||
await lastMessage.Delete();
|
||||
await lastMessage.Delete().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
lastMessage = await ch.SendMessage(msg);
|
||||
lastMessage = await ch.SendMessage(msg).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@ -66,7 +66,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
// if both null, disable
|
||||
if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
||||
{
|
||||
await e.Channel.SendMessage("Repeating disabled");
|
||||
await e.Channel.SendMessage("Repeating disabled").ConfigureAwait(false);
|
||||
Repeater rep;
|
||||
if (repeaters.TryGetValue(e.Server, out rep))
|
||||
rep.MessageTimer.Stop();
|
||||
@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
int minutes;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -98,7 +98,8 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
await e.Channel.SendMessage(String.Format("👌 Repeating `{0}` every " +
|
||||
"**{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 NadekoBot.Classes.JSONModels;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Classes.JSONModels;
|
||||
using NadekoBot.Modules.Music;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
using System;
|
||||
@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
NadekoBot.Config.IsRotatingStatus = timer.Enabled;
|
||||
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)
|
||||
@ -108,7 +108,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
NadekoBot.Config.RotatingStatuses.Add(arg);
|
||||
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")
|
||||
@ -119,13 +119,13 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
if (NadekoBot.Config.RotatingStatuses.Count == 0)
|
||||
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();
|
||||
for (var i = 0; i < NadekoBot.Config.RotatingStatuses.Count; 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")
|
||||
@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
NadekoBot.Config.RotatingStatuses.RemoveAt(num - 1);
|
||||
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
|
||||
{
|
||||
await e.Message.Delete();
|
||||
await e.Message.Delete().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
return;
|
||||
@ -54,13 +54,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
ConcurrentDictionary<ulong, DateTime> 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;
|
||||
}
|
||||
if (RatelimitingChannels.TryAdd(e.Channel.Id, new ConcurrentDictionary<ulong, DateTime>()))
|
||||
{
|
||||
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);
|
||||
if (ch == null)
|
||||
ch = await NadekoBot.Client.CreatePrivateChannel((ulong)r.ChannelId);
|
||||
ch = await NadekoBot.Client.CreatePrivateChannel((ulong)r.ChannelId).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
ch = NadekoBot.Client.GetServer((ulong)r.ServerId)?.GetChannel((ulong)r.ChannelId);
|
||||
@ -53,7 +53,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (ch == null)
|
||||
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)
|
||||
{
|
||||
@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (meorchStr == "ME")
|
||||
{
|
||||
isPrivate = true;
|
||||
ch = await e.User.CreatePMChannel();
|
||||
ch = await e.User.CreatePMChannel().ConfigureAwait(false);
|
||||
}
|
||||
else if (meorchStr == "HERE")
|
||||
{
|
||||
@ -101,7 +101,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
(groupName == "hours" && value > 23) ||
|
||||
(groupName == "minutes" && value > 59))
|
||||
{
|
||||
await e.Channel.SendMessage($"Invalid {groupName} value.");
|
||||
await e.Channel.SendMessage($"Invalid {groupName} value.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -163,7 +163,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
await e.Channel.SendMessage(msg.ToString());
|
||||
await e.Channel.SendMessage(msg.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".rsar")
|
||||
@ -52,17 +52,17 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
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;
|
||||
}
|
||||
var config = SpecificConfigurations.Default.Of(e.Server.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;
|
||||
}
|
||||
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")
|
||||
@ -90,7 +90,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
config.ListOfSelfAssignableRoles.Remove(id);
|
||||
}
|
||||
await e.Channel.SendMessage(msg.ToString());
|
||||
await e.Channel.SendMessage(msg.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".iam")
|
||||
@ -106,22 +106,22 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
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;
|
||||
}
|
||||
var config = SpecificConfigurations.Default.Of(e.Server.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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
await e.User.AddRoles(role);
|
||||
await e.Channel.SendMessage($":ok:You now have {role.Name} role.");
|
||||
await e.User.AddRoles(role).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($":ok:You now have {role.Name} role.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".iamn")
|
||||
@ -138,22 +138,22 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||
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;
|
||||
}
|
||||
var config = SpecificConfigurations.Default.Of(e.Server.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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
await e.User.RemoveRoles(role);
|
||||
await e.Channel.SendMessage($":ok:Successfuly removed {role.Name} role from you.");
|
||||
await e.User.RemoveRoles(role).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage($":ok:Successfuly removed {role.Name} role from you.").ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
Greeted++;
|
||||
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 { }
|
||||
@ -68,11 +68,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
if (channel == null) return;
|
||||
Greeted++;
|
||||
var toDelete = await channel.SendMessage(msg);
|
||||
var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
||||
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages)
|
||||
{
|
||||
await Task.Delay(300000); // 5 minutes
|
||||
await toDelete.Delete();
|
||||
await Task.Delay(300000).ConfigureAwait(false); // 5 minutes
|
||||
await toDelete.Delete().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,17 +95,17 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (controls.GreetPM)
|
||||
{
|
||||
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
|
||||
{
|
||||
if (channel == null) return;
|
||||
Greeted++;
|
||||
var toDelete = await channel.SendMessage(msg);
|
||||
var toDelete = await channel.SendMessage(msg).ConfigureAwait(false);
|
||||
if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages)
|
||||
{
|
||||
await Task.Delay(300000); // 5 minutes
|
||||
await toDelete.Delete();
|
||||
await Task.Delay(300000).ConfigureAwait(false); // 5 minutes
|
||||
await toDelete.Delete().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -219,9 +219,9 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
var controls = AnnouncementsDictionary[e.Server.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
|
||||
await e.Channel.SendMessage("Greet announcements disabled.");
|
||||
await e.Channel.SendMessage("Greet announcements disabled.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
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[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)
|
||||
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")
|
||||
@ -251,9 +251,9 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
var controls = AnnouncementsDictionary[e.Server.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
|
||||
await e.Channel.SendMessage("Bye announcements disabled.");
|
||||
await e.Channel.SendMessage("Bye announcements disabled.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
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[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)
|
||||
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")
|
||||
@ -282,11 +282,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
AnnouncementsDictionary[e.Server.Id].ToggleByePM();
|
||||
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
|
||||
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)
|
||||
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")
|
||||
@ -299,11 +299,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
AnnouncementsDictionary[e.Server.Id].ToggleGreetPM();
|
||||
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
|
||||
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)
|
||||
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;
|
||||
if (subscribers.ContainsKey(voiceChannel))
|
||||
{
|
||||
await e.Channel.SendMessage("`Voice channel notifications disabled.`");
|
||||
await e.Channel.SendMessage("`Voice channel notifications disabled.`").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
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(
|
||||
"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
|
||||
config.VoicePlusTextEnabled = false;
|
||||
@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
if (textChannel != null)
|
||||
await textChannel.AddPermissionsRule(e.Before,
|
||||
new ChPermOverride(readMessages: PermValue.Deny,
|
||||
sendMessages: PermValue.Deny));
|
||||
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
||||
}
|
||||
var afterVch = e.After.VoiceChannel;
|
||||
if (afterVch != null)
|
||||
@ -61,14 +61,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
.FirstOrDefault();
|
||||
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,
|
||||
new ChPermOverride(readMessages: PermValue.Deny,
|
||||
sendMessages: PermValue.Deny));
|
||||
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
||||
}
|
||||
await textChannel.AddPermissionsRule(e.After,
|
||||
new ChPermOverride(readMessages: PermValue.Allow,
|
||||
sendMessages: PermValue.Allow));
|
||||
sendMessages: PermValue.Allow)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -101,27 +101,28 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
try
|
||||
{
|
||||
await textChannel.Delete();
|
||||
await textChannel.Delete().ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await
|
||||
e.Channel.SendMessage(
|
||||
":anger: Error: Most likely i don't have permissions to do this.");
|
||||
await e.Channel.SendMessage(
|
||||
":anger: Error: Most likely i don't have permissions to do this.")
|
||||
.ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
await e.Channel.SendMessage("Successfuly removed voice + text feature.");
|
||||
await e.Channel.SendMessage("Successfuly removed voice + text feature.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
config.VoicePlusTextEnabled = true;
|
||||
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)
|
||||
{
|
||||
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
|
||||
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
|
||||
await Task.Delay(new TimeSpan(24, 0, 0), endTokenSource.Token);
|
||||
await Task.Delay(new TimeSpan(24, 0, 0), endTokenSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
finally
|
||||
@ -115,7 +115,7 @@ namespace NadekoBot.Classes.ClashOfClans
|
||||
{
|
||||
while (!endTokenSource.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(5000);
|
||||
await Task.Delay(5000).ConfigureAwait(false);
|
||||
for (var i = 0; i < bases.Length; i++)
|
||||
{
|
||||
if (bases[i] == null) continue;
|
||||
|
@ -46,7 +46,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
int size;
|
||||
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;
|
||||
}
|
||||
var cw = new ClashWar(enemyClan, size, e);
|
||||
@ -58,7 +58,8 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
{
|
||||
await
|
||||
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 { }
|
||||
};
|
||||
@ -66,11 +67,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
{
|
||||
try
|
||||
{
|
||||
await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**");
|
||||
await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**").ConfigureAwait(false);
|
||||
}
|
||||
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.
|
||||
});
|
||||
|
||||
@ -83,19 +84,19 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
var warsInfo = GetInfo(e);
|
||||
if (warsInfo == null)
|
||||
{
|
||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var war = warsInfo.Item1[warsInfo.Item2];
|
||||
try
|
||||
{
|
||||
var startTask = war.Start();
|
||||
await e.Channel.SendMessage($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**");
|
||||
await startTask;
|
||||
await e.Channel.SendMessage($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**").ConfigureAwait(false);
|
||||
await startTask.ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
if (wars == null || wars.Count == 0)
|
||||
{
|
||||
await e.Channel.SendMessage("🔰 **No active wars.**");
|
||||
await e.Channel.SendMessage("🔰 **No active wars.**").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -126,17 +127,17 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**");
|
||||
sb.AppendLine("**-------------------------**");
|
||||
}
|
||||
await e.Channel.SendMessage(sb.ToString());
|
||||
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
//if number is not null, print the war needed
|
||||
var warsInfo = GetInfo(e);
|
||||
if (warsInfo == null)
|
||||
{
|
||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false);
|
||||
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")
|
||||
@ -151,13 +152,13 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
var warsInfo = GetInfo(e);
|
||||
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;
|
||||
}
|
||||
int 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;
|
||||
}
|
||||
var usr =
|
||||
@ -168,11 +169,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
{
|
||||
var war = warsInfo.Item1[warsInfo.Item2];
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
var usr =
|
||||
@ -198,11 +199,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
var usr =
|
||||
@ -228,11 +229,11 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
{
|
||||
var war = warsInfo.Item1[warsInfo.Item2];
|
||||
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)
|
||||
{
|
||||
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);
|
||||
if (warsInfo == null)
|
||||
{
|
||||
await e.Channel.SendMessage("💢🔰 That war does not exist.");
|
||||
await e.Channel.SendMessage("💢🔰 That war does not exist.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
warsInfo.Item1[warsInfo.Item2].End();
|
||||
|
@ -24,7 +24,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
return;
|
||||
if (CopiedUsers.Contains(e.User.Id))
|
||||
{
|
||||
await e.Channel.SendMessage(e.Message.Text);
|
||||
await e.Channel.SendMessage(e.Message.Text).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
@ -35,7 +35,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
if (CopiedUsers.Contains(e.User.Id)) return;
|
||||
|
||||
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)
|
||||
@ -56,7 +56,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
if (!CopiedUsers.Contains(e.User.Id)) return;
|
||||
|
||||
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
|
||||
{
|
||||
await e.Channel.SendMessage("Something went wrong.");
|
||||
await e.Channel.SendMessage("Something went wrong.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendMessage("Thank you for your request.");
|
||||
await e.Channel.SendMessage("Thank you for your request.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("lr")
|
||||
.Description("PMs the user all current nadeko requests.")
|
||||
.Do(async e =>
|
||||
{
|
||||
var str = await Task.Run(() => GetRequests());
|
||||
var str = await Task.Run(() => GetRequests()).ConfigureAwait(false);
|
||||
if (str.Trim().Length > 110)
|
||||
await e.User.Send(str);
|
||||
await e.User.Send(str).ConfigureAwait(false);
|
||||
else
|
||||
await e.User.Send("No requests atm.");
|
||||
await e.User.Send("No requests atm.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("dr")
|
||||
@ -89,19 +89,19 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
{
|
||||
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
|
||||
{
|
||||
await e.Channel.SendMessage("No request on that number.");
|
||||
await e.Channel.SendMessage("No request on that number.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
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")
|
||||
@ -116,20 +116,20 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
var sc = ResolveRequest(int.Parse(e.Args[0]));
|
||||
if (sc != null)
|
||||
{
|
||||
await e.Channel.SendMessage(e.User.Mention + " Request resolved, notice sent.");
|
||||
await NadekoBot.Client.GetServer((ulong)sc.ServerId).GetUser((ulong)sc.UserId).Send("**This request of yours has been resolved:**\n" + sc.RequestText);
|
||||
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).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await e.Channel.SendMessage("No request on that number.");
|
||||
await e.Channel.SendMessage("No request on that number.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
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");
|
||||
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
|
||||
await e.Channel.SendMessage($"{other} did it. 😒 🔫");
|
||||
await e.Channel.SendMessage($"{other} did it. 😒 🔫").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("comeatmebro")
|
||||
@ -54,28 +54,25 @@ namespace NadekoBot.Modules.Conversations
|
||||
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
|
||||
if (usr == null)
|
||||
{
|
||||
await e.Channel.SendMessage("(ง’̀-‘́)ง");
|
||||
await e.Channel.SendMessage("(ง’̀-‘́)ง").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendMessage($"{usr.Mention} (ง’̀-‘́)ง");
|
||||
await e.Channel.SendMessage($"{usr.Mention} (ง’̀-‘́)ง").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
|
||||
cgb.CreateCommand("\\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/")
|
||||
.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")
|
||||
.Description("Suggests moving the conversation.\n**Usage**: moveto #spam")
|
||||
.Parameter("target", ParameterType.Unparsed)
|
||||
.Do(async e =>
|
||||
{
|
||||
await e.Channel.SendMessage($"(👉 ͡° ͜ʖ ͡°)👉 {e.GetArg("target")}");
|
||||
});
|
||||
.Do(async e => await e.Channel.SendMessage($"(👉 ͡° ͜ʖ ͡°)👉 {e.GetArg("target")}"));
|
||||
|
||||
|
||||
cgb.CreateCommand("..")
|
||||
@ -94,9 +91,9 @@ namespace NadekoBot.Modules.Conversations
|
||||
Keyword = e.GetArg("keyword").ToLowerInvariant(),
|
||||
Text = text,
|
||||
UserName = e.User.Name,
|
||||
}));
|
||||
})).ConfigureAwait(false);
|
||||
|
||||
await e.Channel.SendMessage("`New quote added.`");
|
||||
await e.Channel.SendMessage("`New quote added.`").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("...")
|
||||
@ -113,9 +110,9 @@ namespace NadekoBot.Modules.Conversations
|
||||
uqm => uqm.Keyword == keyword);
|
||||
|
||||
if (quote != null)
|
||||
await e.Channel.SendMessage($"📣 {quote.Text}");
|
||||
await e.Channel.SendMessage($"📣 {quote.Text}").ConfigureAwait(false);
|
||||
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 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")
|
||||
@ -142,12 +139,12 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
if (NadekoBot.IsOwner(e.User.Id))
|
||||
{
|
||||
await e.Channel.SendMessage(e.User.Mention + ", Yes, my love.");
|
||||
await Task.Delay(5000);
|
||||
await e.Channel.SendMessage(e.User.Mention + ", Yes, my love.").ConfigureAwait(false);
|
||||
await Task.Delay(5000).ConfigureAwait(false);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
else
|
||||
await e.Channel.SendMessage(e.User.Mention + ", No.");
|
||||
await e.Channel.SendMessage(e.User.Mention + ", No.").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
var randServerSw = new Stopwatch();
|
||||
@ -158,9 +155,9 @@ namespace NadekoBot.Modules.Conversations
|
||||
.Do(async e =>
|
||||
{
|
||||
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
|
||||
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")
|
||||
@ -170,17 +167,17 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
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;
|
||||
}
|
||||
var kw = e.Server.GetUser(NadekoBot.Creds.OwnerIds[0]);
|
||||
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
|
||||
{
|
||||
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();
|
||||
if (u == null)
|
||||
{
|
||||
await e.Channel.SendMessage("Invalid user specified.");
|
||||
await e.Channel.SendMessage("Invalid user specified.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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")
|
||||
@ -213,16 +210,16 @@ namespace NadekoBot.Modules.Conversations
|
||||
|
||||
if (u == null)
|
||||
{
|
||||
await e.Channel.SendMessage("Invalid user specified.");
|
||||
await e.Channel.SendMessage("Invalid user specified.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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")
|
||||
@ -239,11 +236,12 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
await e.Channel.SendMessage(
|
||||
$"{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
|
||||
{
|
||||
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
|
||||
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
|
||||
{
|
||||
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
|
||||
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
|
||||
{
|
||||
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.")
|
||||
.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")
|
||||
@ -295,7 +296,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
.Description("Nadeko instructs you to type $draw. Gambling functions start with $")
|
||||
.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")
|
||||
.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;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -317,7 +318,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
str += firestr;
|
||||
}
|
||||
await e.Channel.SendMessage(str);
|
||||
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("rip")
|
||||
@ -331,9 +332,11 @@ namespace NadekoBot.Modules.Conversations
|
||||
var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
|
||||
var text = "";
|
||||
text = usr?.Name ?? e.GetArg("user");
|
||||
await
|
||||
e.Channel.SendFile("ripzor_m8.png",
|
||||
RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year")) ? null : e.GetArg("year")));
|
||||
await e.Channel.SendFile("ripzor_m8.png",
|
||||
RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year"))
|
||||
? null
|
||||
: e.GetArg("year")))
|
||||
.ConfigureAwait(false);
|
||||
});
|
||||
if (!NadekoBot.Config.DontJoinServers)
|
||||
{
|
||||
@ -342,21 +345,21 @@ namespace NadekoBot.Modules.Conversations
|
||||
.Parameter("id", ParameterType.Required)
|
||||
.Do(async e =>
|
||||
{
|
||||
var invite = await client.GetInvite(e.Args[0]);
|
||||
var invite = await client.GetInvite(e.Args[0]).ConfigureAwait(false);
|
||||
if (invite != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await invite.Accept();
|
||||
await invite.Accept().ConfigureAwait(false);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
var msgs = (await e.Channel.DownloadMessages(100))
|
||||
var msgs = (await e.Channel.DownloadMessages(100).ConfigureAwait(false))
|
||||
.Where(m => m.MentionedUsers.Contains(e.User))
|
||||
.OrderByDescending(m => m.Timestamp);
|
||||
if (msgs.Any())
|
||||
@ -377,7 +380,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
Message lastMessage = null;
|
||||
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
|
||||
.Where(m => m.MentionedUsers.Contains(e.User))
|
||||
.OrderByDescending(m => m.Timestamp)
|
||||
@ -386,9 +389,10 @@ namespace NadekoBot.Modules.Conversations
|
||||
}
|
||||
}
|
||||
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
|
||||
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")
|
||||
@ -402,7 +406,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
if (u.Id != NadekoBot.Client.CurrentUser.Id)
|
||||
str += " " + u.Mention;
|
||||
}
|
||||
await e.Channel.SendMessage(str);
|
||||
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("call")
|
||||
@ -410,7 +414,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
.Parameter("who", ParameterType.Required)
|
||||
.Do(async e =>
|
||||
{
|
||||
await e.Channel.SendMessage("Calling " + e.Args[0] + "...");
|
||||
await e.Channel.SendMessage("Calling " + e.Args[0] + "...").ConfigureAwait(false);
|
||||
});
|
||||
cgb.CreateCommand("hide")
|
||||
.Description("Hides Nadeko in plain sight!11!!")
|
||||
@ -418,9 +422,9 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
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")
|
||||
@ -429,9 +433,9 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
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")
|
||||
@ -446,7 +450,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
try
|
||||
{
|
||||
var invite = await s.CreateInvite(0);
|
||||
var invite = await s.CreateInvite(0).ConfigureAwait(false);
|
||||
invites += invite.Url + "\n";
|
||||
i++;
|
||||
}
|
||||
@ -457,7 +461,8 @@ namespace NadekoBot.Modules.Conversations
|
||||
}
|
||||
}
|
||||
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")
|
||||
@ -471,7 +476,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
{
|
||||
construct += strings[rng.Next(0, strings.Length)];
|
||||
}
|
||||
await e.Channel.SendMessage(construct);
|
||||
await e.Channel.SendMessage(construct).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("av").Alias("avatar")
|
||||
@ -482,10 +487,10 @@ namespace NadekoBot.Modules.Conversations
|
||||
var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
|
||||
if (usr == null)
|
||||
{
|
||||
await e.Channel.SendMessage("Invalid user specified.");
|
||||
await e.Channel.SendMessage("Invalid user specified.").ConfigureAwait(false);
|
||||
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()
|
||||
=> 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);
|
||||
|
||||
await e.Channel.SendFile("dice.png", imageStream);
|
||||
await e.Channel.SendFile("dice.png", imageStream).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
Match m;
|
||||
@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
arr[i] = r.Next(1, n2 + 1);
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -83,7 +83,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
if (num < 1) num = 1;
|
||||
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;
|
||||
}
|
||||
var dices = new List<Image>(num);
|
||||
@ -108,12 +108,12 @@ namespace NadekoBot.Modules.Gambling
|
||||
}
|
||||
|
||||
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.SendFile("dice.png", bitmap.ToStream(ImageFormat.Png));
|
||||
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)).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
await e.Channel.SendMessage($"{e.User.Mention} rolled **{rolled}**.");
|
||||
await e.Channel.SendMessage($"{e.User.Mention} rolled **{rolled}**.").ConfigureAwait(false);
|
||||
}
|
||||
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;
|
||||
});
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (num > 5)
|
||||
@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
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;
|
||||
}
|
||||
var currentCard = cards.DrawACard();
|
||||
@ -76,10 +76,10 @@ namespace NadekoBot.Modules.Gambling
|
||||
images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image);
|
||||
}
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(Cards.GetHandValue(cardObjects));
|
||||
await e.Channel.SendMessage(Cards.GetHandValue(cardObjects)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -30,11 +30,12 @@ namespace NadekoBot.Modules.Gambling
|
||||
if (e.GetArg("count") == "")
|
||||
{
|
||||
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
|
||||
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;
|
||||
if (int.TryParse(e.GetArg("count"), out result))
|
||||
{
|
||||
@ -47,10 +48,10 @@ namespace NadekoBot.Modules.Gambling
|
||||
Properties.Resources.tails :
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
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")
|
||||
@ -112,7 +112,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
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;
|
||||
}
|
||||
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();
|
||||
if (role == null)
|
||||
{
|
||||
await e.Channel.SendMessage("💢 Role not found.");
|
||||
await e.Channel.SendMessage("💢 Role not found.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var members = role.Members.Where(u => u.Status == UserStatus.Online); // only online
|
||||
var membersArray = members as User[] ?? members.ToArray();
|
||||
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.")
|
||||
.Do(async e =>
|
||||
{
|
||||
await ReceiveAnswer(e, Answers.Betray);
|
||||
await ReceiveAnswer(e, Answers.Betray).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Module.Prefix + "cooperate")
|
||||
@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
.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" +
|
||||
$"Nadeko has {NadekoPoints} points." +
|
||||
$"You have {UserPoints} points." +
|
||||
$"--------------------------------\n");
|
||||
$"--------------------------------\n")
|
||||
.ConfigureAwait(false);
|
||||
if (round < 10) return;
|
||||
if (nadekoPoints == userPoints)
|
||||
await e.Channel.SendMessage("Its a draw");
|
||||
await e.Channel.SendMessage("Its a draw").ConfigureAwait(false);
|
||||
else if (nadekoPoints > userPoints)
|
||||
await e.Channel.SendMessage("Nadeko won.");
|
||||
await e.Channel.SendMessage("Nadeko won.").ConfigureAwait(false);
|
||||
else
|
||||
await e.Channel.SendMessage("You won.");
|
||||
await e.Channel.SendMessage("You won.").ConfigureAwait(false);
|
||||
nadekoPoints = 0;
|
||||
userPoints = 0;
|
||||
round = 0;
|
||||
|
@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
boardStr.AppendLine();
|
||||
}
|
||||
if (godMsg.Id != 0)
|
||||
await godMsg.Edit(boardStr.ToString());
|
||||
await godMsg.Edit(boardStr.ToString()).ConfigureAwait(false);
|
||||
|
||||
};
|
||||
t.Interval = 1000;
|
||||
@ -93,7 +93,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
// {
|
||||
// if (gameChannel != null)
|
||||
// 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;
|
||||
// players[0] = new BombermanPlayer
|
||||
// {
|
||||
|
@ -309,7 +309,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
return;
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
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;
|
||||
|
||||
await e.Message.Delete();
|
||||
await e.Message.Delete().ConfigureAwait(false);
|
||||
if (!plantedFlowerChannels.TryRemove(e.Channel.Id, out msg))
|
||||
return;
|
||||
|
||||
await msg.Delete();
|
||||
await FlowersHandler.AddFlowersAsync(e.User, "Picked a flower.", 1, true);
|
||||
msg = await e.Channel.SendMessage($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!");
|
||||
await Task.Delay(10000);
|
||||
await msg.Delete();
|
||||
await msg.Delete().ConfigureAwait(false);
|
||||
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}!").ConfigureAwait(false);
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
await msg.Delete().ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Module.Prefix + "plant")
|
||||
@ -68,6 +68,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
var rng = new Random();
|
||||
var file = Directory.GetFiles("data/currency_images").OrderBy(s => rng.Next()).FirstOrDefault();
|
||||
Message msg;
|
||||
//todo send message after, not in lock
|
||||
if (file == null)
|
||||
msg = e.Channel.SendMessage(NadekoBot.Config.CurrencySign).GetAwaiter().GetResult();
|
||||
else
|
||||
@ -76,8 +77,8 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
}
|
||||
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");
|
||||
await Task.Delay(20000);
|
||||
await msg2.Delete();
|
||||
await Task.Delay(20000).ConfigureAwait(false);
|
||||
await msg2.Delete().ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
var poll = new Poll(e, data[0], data.Skip(1));
|
||||
if (PollCommand.ActivePolls.TryAdd(e.Server, poll))
|
||||
{
|
||||
await poll.StartPoll();
|
||||
await poll.StartPoll().ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
cgb.CreateCommand(Module.Prefix + "pollend")
|
||||
.Description("Stops active poll on this server and prints the results in this channel.")
|
||||
@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
return;
|
||||
if (!ActivePolls.ContainsKey(e.Server))
|
||||
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;
|
||||
msgToSend = answers.Aggregate(msgToSend, (current, answ) => current + $"`{num++}.` **{answ}**\n");
|
||||
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)
|
||||
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
var totalVotesCast = results.Sum(kvp => kvp.Value);
|
||||
if (totalVotesCast == 0)
|
||||
{
|
||||
await ch.SendMessage("📄 **No votes have been cast.**");
|
||||
await ch.SendMessage("📄 **No votes have been cast.**").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var closeMessage = $"--------------**POLL CLOSED**--------------\n" +
|
||||
@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
$" has {kvp.Value} votes." +
|
||||
$"({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)
|
||||
{
|
||||
@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
return;
|
||||
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 { }
|
||||
|
@ -56,7 +56,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
IsActive = false;
|
||||
sw.Stop();
|
||||
sw.Reset();
|
||||
await channel.Send("Typing contest stopped");
|
||||
await channel.Send("Typing contest stopped").ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -68,28 +68,28 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
IsActive = true;
|
||||
CurrentSentence = SentencesProvider.GetRandomSentence();
|
||||
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**...");
|
||||
await Task.Delay(1000);
|
||||
await msg.Edit("Starting new typing contest in **2**...");
|
||||
await Task.Delay(1000);
|
||||
await msg.Edit("Starting new typing contest in **1**...");
|
||||
await Task.Delay(1000);
|
||||
await msg.Edit($":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:");
|
||||
var msg = await channel.SendMessage("Starting new typing contest in **3**...").ConfigureAwait(false);
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
await msg.Edit("Starting new typing contest in **2**...").ConfigureAwait(false);
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
await msg.Edit("Starting new typing contest in **1**...").ConfigureAwait(false);
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
await msg.Edit($":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:").ConfigureAwait(false);
|
||||
sw.Start();
|
||||
HandleAnswers();
|
||||
|
||||
while (i > 0)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
i--;
|
||||
if (!IsActive)
|
||||
return;
|
||||
}
|
||||
|
||||
await Stop();
|
||||
await Stop().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,10 +111,10 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
if (decision && !finishedUserIds.Contains(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)
|
||||
{
|
||||
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(
|
||||
$"Contest already running in " +
|
||||
$"{game.Channell.Mention} channel.");
|
||||
$"{game.Channell.Mention} channel.")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await game.Start();
|
||||
await game.Start().ConfigureAwait(false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -158,10 +159,10 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
TypingGame game;
|
||||
if (RunningContests.TryRemove(e.User.Server.Id, out game))
|
||||
{
|
||||
await game.Stop();
|
||||
await game.Stop().ConfigureAwait(false);
|
||||
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)
|
||||
@ -187,7 +188,7 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
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
|
||||
|
@ -53,13 +53,13 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
||||
CurrentQuestion = TriviaQuestionPool.Instance.GetRandomQuestion(oldQuestions);
|
||||
if (CurrentQuestion == null)
|
||||
{
|
||||
await channel.SendMessage($":exclamation: Failed loading a trivia question");
|
||||
await End();
|
||||
await channel.SendMessage($":exclamation: Failed loading a trivia question").ConfigureAwait(false);
|
||||
await End().ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
oldQuestions.Add(CurrentQuestion); //add it to exclusion list so it doesn't show up again
|
||||
//sendquestion
|
||||
await channel.SendMessage($":question: **{CurrentQuestion.Question}**");
|
||||
await channel.SendMessage($":question: **{CurrentQuestion.Question}**").ConfigureAwait(false);
|
||||
|
||||
//receive messages
|
||||
NadekoBot.Client.MessageReceived += PotentialGuess;
|
||||
@ -70,12 +70,12 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
||||
try
|
||||
{
|
||||
//hint
|
||||
await Task.Delay(HintTimeoutMiliseconds, token);
|
||||
await Task.Delay(HintTimeoutMiliseconds, token).ConfigureAwait(false);
|
||||
if (ShowHints)
|
||||
await channel.SendMessage($":exclamation:**Hint:** {CurrentQuestion.GetHint()}");
|
||||
await channel.SendMessage($":exclamation:**Hint:** {CurrentQuestion.GetHint()}").ConfigureAwait(false);
|
||||
|
||||
//timeout
|
||||
await Task.Delay(QuestionDurationMiliseconds - HintTimeoutMiliseconds, token);
|
||||
await Task.Delay(QuestionDurationMiliseconds - HintTimeoutMiliseconds, token).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
@ -84,18 +84,18 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
||||
}
|
||||
GameActive = false;
|
||||
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;
|
||||
// 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()
|
||||
{
|
||||
ShouldStopGame = true;
|
||||
await channel.SendMessage("**Trivia game ended**\n" + GetLeaderboard());
|
||||
await channel.SendMessage("**Trivia game ended**\n" + GetLeaderboard()).ConfigureAwait(false);
|
||||
TriviaGame throwAwayValue;
|
||||
TriviaCommands.RunningTrivias.TryRemove(server.Id, out throwAwayValue);
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
||||
public async Task StopGame()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -127,12 +127,12 @@ namespace NadekoBot.Modules.Games.Commands.Trivia
|
||||
}
|
||||
if (!guess) return;
|
||||
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;
|
||||
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
|
||||
await FlowersHandler.AddFlowersAsync(e.User, "Won Trivia", 2);
|
||||
await FlowersHandler.AddFlowersAsync(e.User, "Won Trivia", 2).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
var showHints = !e.Args.Contains("nohint");
|
||||
var triviaGame = new TriviaGame(e, showHints);
|
||||
if (RunningTrivias.TryAdd(e.Server.Id, triviaGame))
|
||||
await e.Channel.SendMessage("**Trivia game started!**");
|
||||
await e.Channel.SendMessage("**Trivia game started!**").ConfigureAwait(false);
|
||||
else
|
||||
await triviaGame.StopGame();
|
||||
await triviaGame.StopGame().ConfigureAwait(false);
|
||||
}
|
||||
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")
|
||||
@ -43,9 +43,9 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
{
|
||||
TriviaGame trivia;
|
||||
if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
|
||||
await e.Channel.SendMessage(trivia.GetLeaderboard());
|
||||
await e.Channel.SendMessage(trivia.GetLeaderboard()).ConfigureAwait(false);
|
||||
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")
|
||||
@ -55,10 +55,10 @@ namespace NadekoBot.Modules.Games.Commands
|
||||
TriviaGame trivia;
|
||||
if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
|
||||
{
|
||||
await trivia.StopGame();
|
||||
await trivia.StopGame().ConfigureAwait(false);
|
||||
}
|
||||
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(';');
|
||||
if (list.Count() < 2)
|
||||
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")
|
||||
@ -60,7 +60,8 @@ namespace NadekoBot.Modules.Games
|
||||
try
|
||||
{
|
||||
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 { }
|
||||
});
|
||||
@ -102,7 +103,7 @@ namespace NadekoBot.Modules.Games
|
||||
else
|
||||
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")
|
||||
@ -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.
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
await Task.Delay(200);
|
||||
await Task.Delay(200).ConfigureAwait(false);
|
||||
}
|
||||
*/
|
||||
#endregion OldHelp
|
||||
|
||||
if (string.IsNullOrWhiteSpace(e.GetArg("command")))
|
||||
{
|
||||
await e.User.Send(HelpString);
|
||||
await e.User.Send(HelpString).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await Task.Run(async () =>
|
||||
@ -51,8 +51,8 @@ namespace NadekoBot.Classes.Help.Commands
|
||||
var com = NadekoBot.Client.GetService<CommandService>().AllCommands
|
||||
.FirstOrDefault(c => c.Text.ToLower().Equals(comToFind));
|
||||
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
|
||||
? $"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>
|
||||
|
||||
**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")
|
||||
.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.
|
||||
|
||||
*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.")
|
||||
.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")
|
||||
@ -43,10 +44,11 @@ namespace NadekoBot.Modules.Help
|
||||
var cmdsArray = cmds as Command[] ?? cmds.ToArray();
|
||||
if (!cmdsArray.Any())
|
||||
{
|
||||
await e.Channel.SendMessage("That module does not exist.");
|
||||
await e.Channel.SendMessage("That module does not exist.").ConfigureAwait(false);
|
||||
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
|
||||
{
|
||||
if (audioClient?.State != ConnectionState.Connected)
|
||||
audioClient = await PlaybackVoiceChannel.JoinAudio();
|
||||
audioClient = await PlaybackVoiceChannel.JoinAudio().ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
continue;
|
||||
}
|
||||
CurrentSong = GetNextSong();
|
||||
@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
try
|
||||
{
|
||||
OnStarted(this, curSong);
|
||||
await curSong.Play(audioClient, cancelToken);
|
||||
await curSong.Play(audioClient, cancelToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
SongCancelSource = new CancellationTokenSource();
|
||||
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)
|
||||
throw new ArgumentNullException(nameof(s));
|
||||
lock (playlistLock) {
|
||||
lock (playlistLock)
|
||||
{
|
||||
playlist.Insert(index, s);
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
throw new ArgumentException();
|
||||
while (ContentLength + count > BufferSize)
|
||||
{
|
||||
await Task.Delay(20, cancelToken);
|
||||
await Task.Delay(20, cancelToken).ConfigureAwait(false);
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
return;
|
||||
}
|
||||
|
@ -90,7 +90,8 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
var read = 0;
|
||||
try
|
||||
{
|
||||
read = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, blockSize, cancelToken);
|
||||
read = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, blockSize, cancelToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -100,10 +101,10 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
if (attempt++ == 50)
|
||||
break;
|
||||
else
|
||||
await Task.Delay(100, cancelToken);
|
||||
await Task.Delay(100, cancelToken).ConfigureAwait(false);
|
||||
else
|
||||
attempt = 0;
|
||||
await songBuffer.WriteAsync(buffer, read, cancelToken);
|
||||
await songBuffer.WriteAsync(buffer, read, cancelToken).ConfigureAwait(false);
|
||||
if (songBuffer.ContentLength > 2.MB())
|
||||
prebufferingComplete = true;
|
||||
}
|
||||
@ -135,7 +136,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
var toAttemptTimes = SongInfo.ProviderType != MusicType.Normal ? 5 : 9;
|
||||
while (!prebufferingComplete && bufferAttempts++ < toAttemptTimes)
|
||||
{
|
||||
await Task.Delay(waitPerAttempt, cancelToken);
|
||||
await Task.Delay(waitPerAttempt, cancelToken).ConfigureAwait(false);
|
||||
}
|
||||
cancelToken.ThrowIfCancellationRequested();
|
||||
Console.WriteLine($"Prebuffering done? in {waitPerAttempt * bufferAttempts}");
|
||||
@ -158,12 +159,12 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
break;
|
||||
}
|
||||
else
|
||||
await Task.Delay(100, cancelToken);
|
||||
await Task.Delay(100, cancelToken).ConfigureAwait(false);
|
||||
else
|
||||
attempt = 0;
|
||||
|
||||
while (this.MusicPlayer.Paused)
|
||||
await Task.Delay(200, cancelToken);
|
||||
await Task.Delay(200, cancelToken).ConfigureAwait(false);
|
||||
buffer = AdjustVolume(buffer, MusicPlayer.Volume);
|
||||
voiceClient.Send(buffer, 0, read);
|
||||
}
|
||||
@ -209,7 +210,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
if (musicType != MusicType.Local && IsRadioLink(query))
|
||||
{
|
||||
musicType = MusicType.Radio;
|
||||
query = await HandleStreamContainers(query) ?? query;
|
||||
query = await HandleStreamContainers(query).ConfigureAwait(false) ?? query;
|
||||
}
|
||||
|
||||
try
|
||||
@ -237,7 +238,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
}
|
||||
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
|
||||
{
|
||||
Title = svideo.FullName,
|
||||
@ -247,10 +248,10 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
Query = query,
|
||||
});
|
||||
}
|
||||
var link = await SearchHelper.FindYoutubeUrlByKeywords(query);
|
||||
var link = await SearchHelper.FindYoutubeUrlByKeywords(query).ConfigureAwait(false);
|
||||
if (link == String.Empty)
|
||||
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 video = videos
|
||||
.Where(v => v.AudioBitrate < 192)
|
||||
@ -280,7 +281,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
string file = null;
|
||||
try
|
||||
{
|
||||
file = await SearchHelper.GetResponseStringAsync(query);
|
||||
file = await SearchHelper.GetResponseStringAsync(query).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
if (string.IsNullOrWhiteSpace(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);
|
||||
if (responseObj?.Kind != "track")
|
||||
|
@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Music
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
|
||||
musicPlayer.Stop();
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("d")
|
||||
@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Music
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryRemove(e.Server, out musicPlayer)) return;
|
||||
musicPlayer.Destroy();
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("p")
|
||||
@ -101,9 +101,9 @@ namespace NadekoBot.Modules.Music
|
||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
|
||||
musicPlayer.TogglePause();
|
||||
if (musicPlayer.Paused)
|
||||
await e.Channel.SendMessage("🎵`Music Player paused.`");
|
||||
await e.Channel.SendMessage("🎵`Music Player paused.`").ConfigureAwait(false);
|
||||
else
|
||||
await e.Channel.SendMessage("🎵`Music Player unpaused.`");
|
||||
await e.Channel.SendMessage("🎵`Music Player unpaused.`").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("q")
|
||||
@ -113,11 +113,11 @@ namespace NadekoBot.Modules.Music
|
||||
.Parameter("query", ParameterType.Unparsed)
|
||||
.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)
|
||||
{
|
||||
await Task.Delay(10000);
|
||||
await e.Message.Delete();
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
await e.Message.Delete().ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
|
||||
@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Music
|
||||
MusicPlayer 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;
|
||||
}
|
||||
var currentSong = musicPlayer.CurrentSong;
|
||||
@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Music
|
||||
else
|
||||
toSend += "\n";
|
||||
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")
|
||||
@ -161,7 +161,7 @@ namespace NadekoBot.Modules.Music
|
||||
if (currentSong == null)
|
||||
return;
|
||||
await e.Channel.SendMessage($"🎵`Now Playing` {currentSong.PrettyName} " +
|
||||
$"{currentSong.PrettyCurrentTime()}");
|
||||
$"{currentSong.PrettyCurrentTime()}").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("vol")
|
||||
@ -176,11 +176,11 @@ namespace NadekoBot.Modules.Music
|
||||
int volume;
|
||||
if (!int.TryParse(arg, out volume))
|
||||
{
|
||||
await e.Channel.SendMessage("Volume number invalid.");
|
||||
await e.Channel.SendMessage("Volume number invalid.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
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")
|
||||
@ -194,11 +194,11 @@ namespace NadekoBot.Modules.Music
|
||||
float volume;
|
||||
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;
|
||||
}
|
||||
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")
|
||||
@ -240,12 +240,12 @@ namespace NadekoBot.Modules.Music
|
||||
return;
|
||||
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;
|
||||
}
|
||||
|
||||
musicPlayer.Shuffle();
|
||||
await e.Channel.SendMessage("🎵 `Songs shuffled.`");
|
||||
await e.Channel.SendMessage("🎵 `Songs shuffled.`").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("pl")
|
||||
@ -258,24 +258,24 @@ namespace NadekoBot.Modules.Music
|
||||
return;
|
||||
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;
|
||||
}
|
||||
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
|
||||
var idArray = ids as string[] ?? ids.ToArray();
|
||||
var count = idArray.Count();
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
await QueueSong(e.Channel, e.User.VoiceChannel, id, true);
|
||||
await QueueSong(e.Channel, e.User.VoiceChannel, id, true).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
await msg.Edit("🎵 `Playlist queue complete.`");
|
||||
await msg.Edit("🎵 `Playlist queue complete.`").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("lopl")
|
||||
@ -293,9 +293,9 @@ namespace NadekoBot.Modules.Music
|
||||
.Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System));
|
||||
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 { }
|
||||
});
|
||||
@ -307,14 +307,14 @@ namespace NadekoBot.Modules.Music
|
||||
{
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
await Task.Delay(10000);
|
||||
await e.Message.Delete();
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
await e.Message.Delete().ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
|
||||
@ -327,7 +327,7 @@ namespace NadekoBot.Modules.Music
|
||||
var arg = e.GetArg("path");
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
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")
|
||||
@ -355,7 +355,7 @@ namespace NadekoBot.Modules.Music
|
||||
if (arg?.ToLower() == "all")
|
||||
{
|
||||
musicPlayer.ClearQueue();
|
||||
await e.Channel.SendMessage($"🎵`Queue cleared!`");
|
||||
await e.Channel.SendMessage($"🎵`Queue cleared!`").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
int num;
|
||||
@ -367,7 +367,7 @@ namespace NadekoBot.Modules.Music
|
||||
return;
|
||||
var song = (musicPlayer.Playlist as List<Song>)?[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")
|
||||
@ -402,7 +402,8 @@ namespace NadekoBot.Modules.Music
|
||||
var currentValue = musicPlayer.ToggleRepeatSong();
|
||||
await e.Channel.SendMessage(currentValue ?
|
||||
$"🎵🔂`Repeating track:`{currentSong.PrettyName}" :
|
||||
$"🎵🔂`Current track repeat stopped.`");
|
||||
$"🎵🔂`Current track repeat stopped.`")
|
||||
.ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("rpl")
|
||||
@ -414,7 +415,7 @@ namespace NadekoBot.Modules.Music
|
||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
||||
return;
|
||||
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")
|
||||
@ -466,7 +467,7 @@ namespace NadekoBot.Modules.Music
|
||||
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;
|
||||
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;
|
||||
}
|
||||
var name = e.GetArg("name")?.Trim().ToLowerInvariant();
|
||||
@ -511,7 +512,7 @@ namespace NadekoBot.Modules.Music
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -521,12 +522,12 @@ namespace NadekoBot.Modules.Music
|
||||
var songInfos = psis.Select(psi => DbHandler.Instance
|
||||
.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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -568,7 +569,7 @@ namespace NadekoBot.Modules.Music
|
||||
if (seconds.Length == 1)
|
||||
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 (!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));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
|
||||
@ -602,10 +603,10 @@ namespace NadekoBot.Modules.Music
|
||||
try
|
||||
{
|
||||
if (lastFinishedMessage != null)
|
||||
await lastFinishedMessage.Delete();
|
||||
await lastFinishedMessage.Delete().ConfigureAwait(false);
|
||||
if (playingMessage != null)
|
||||
await playingMessage.Delete();
|
||||
lastFinishedMessage = await textCh.SendMessage($"🎵`Finished`{song.PrettyName}");
|
||||
await playingMessage.Delete().ConfigureAwait(false);
|
||||
lastFinishedMessage = await textCh.SendMessage($"🎵`Finished`{song.PrettyName}").ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@ -622,30 +623,30 @@ namespace NadekoBot.Modules.Music
|
||||
{
|
||||
|
||||
var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(sender.Volume * 100)}%`";
|
||||
playingMessage = await textCh.SendMessage(msgTxt);
|
||||
playingMessage = await textCh.SendMessage(msgTxt).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
};
|
||||
return mp;
|
||||
});
|
||||
var resolvedSong = await Song.ResolveSong(query, musicType);
|
||||
var resolvedSong = await Song.ResolveSong(query, musicType).ConfigureAwait(false);
|
||||
resolvedSong.MusicPlayer = musicPlayer;
|
||||
|
||||
musicPlayer.AddSong(resolvedSong);
|
||||
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
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(10000);
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await queuedMessage.Delete();
|
||||
await queuedMessage.Delete().ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,10 @@ namespace NadekoBot.Modules.NSFW
|
||||
.Do(async e =>
|
||||
{
|
||||
var tag = e.GetArg("tag")?.Trim() ?? "";
|
||||
await e.Channel.SendMessage(":heart: Gelbooru: " + await SearchHelper.GetGelbooruImageLink("rating%3Aexplicit+" + tag));
|
||||
await e.Channel.SendMessage(":heart: Danbooru: " + await SearchHelper.GetDanbooruImageLink("rating%3Aexplicit+" + tag));
|
||||
await e.Channel.SendMessage(":heart: Gelbooru: " + await SearchHelper.GetGelbooruImageLink("rating%3Aexplicit+" + tag).ConfigureAwait(false))
|
||||
.ConfigureAwait(false);
|
||||
await e.Channel.SendMessage(":heart: Danbooru: " + await SearchHelper.GetDanbooruImageLink("rating%3Aexplicit+" + tag).ConfigureAwait(false))
|
||||
.ConfigureAwait(false);
|
||||
});
|
||||
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")
|
||||
@ -36,7 +38,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
.Do(async e =>
|
||||
{
|
||||
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")
|
||||
.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 =>
|
||||
{
|
||||
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")
|
||||
.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 =>
|
||||
{
|
||||
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")
|
||||
.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 =>
|
||||
{
|
||||
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")
|
||||
.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 =>
|
||||
{
|
||||
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")
|
||||
.Description("We all know where this will lead you to.")
|
||||
.Parameter("anything", ParameterType.Unparsed)
|
||||
.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")
|
||||
.Description("Real adult content.")
|
||||
@ -83,12 +85,12 @@ namespace NadekoBot.Modules.NSFW
|
||||
{
|
||||
try
|
||||
{
|
||||
var obj = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.oboobs.ru/boobs/{rng.Next(0, 9380)}"))[0];
|
||||
await e.Channel.SendMessage($"http://media.oboobs.ru/{ obj["preview"].ToString() }");
|
||||
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() }").ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await e.Channel.SendMessage($"💢 {ex.Message}");
|
||||
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
cgb.CreateCommand(Prefix + "butts")
|
||||
@ -98,12 +100,12 @@ namespace NadekoBot.Modules.NSFW
|
||||
{
|
||||
try
|
||||
{
|
||||
var obj = JArray.Parse(await SearchHelper.GetResponseStringAsync($"http://api.obutts.ru/butts/{rng.Next(0, 3373)}"))[0];
|
||||
await e.Channel.SendMessage($"http://media.obutts.ru/{ obj["preview"].ToString() }");
|
||||
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() }").ConfigureAwait(false);
|
||||
}
|
||||
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)
|
||||
{
|
||||
//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();
|
||||
}
|
||||
});
|
||||
|
@ -24,13 +24,14 @@ namespace NadekoBot.Modules.Permissions.Commands
|
||||
|
||||
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 " +
|
||||
$"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
|
||||
$"Full message: [[{args.Message.Text}]]");
|
||||
if (serverPerms.Verbose)
|
||||
await args.Channel.SendMessage($"{args.User.Mention} Invite links are not " +
|
||||
$"allowed on this channel.");
|
||||
$"allowed on this channel.")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
@ -71,7 +72,8 @@ namespace NadekoBot.Modules.Permissions.Commands
|
||||
? e.Channel
|
||||
: PermissionHelper.ValidateChannel(e.Server, chanStr);
|
||||
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;
|
||||
}
|
||||
//all channels
|
||||
@ -80,12 +82,14 @@ namespace NadekoBot.Modules.Permissions.Commands
|
||||
{
|
||||
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)
|
||||
{
|
||||
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"));
|
||||
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)
|
||||
{
|
||||
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(' ');
|
||||
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 " +
|
||||
$"BANNED WORD in [{args.Channel.Name}/{args.Channel.Id}] channel. " +
|
||||
$"Full message: [[{args.Message.Text}]]");
|
||||
if (serverPerms.Verbose)
|
||||
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 { }
|
||||
@ -68,7 +69,7 @@ namespace NadekoBot.Modules.Permissions.Commands
|
||||
? e.Channel
|
||||
: PermissionHelper.ValidateChannel(e.Server, chanStr);
|
||||
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;
|
||||
}
|
||||
//all channels
|
||||
@ -77,11 +78,11 @@ namespace NadekoBot.Modules.Permissions.Commands
|
||||
{
|
||||
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)
|
||||
{
|
||||
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))
|
||||
return;
|
||||
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)
|
||||
{
|
||||
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))
|
||||
return;
|
||||
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)
|
||||
{
|
||||
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))
|
||||
return;
|
||||
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)
|
||||
{
|
||||
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"));
|
||||
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)
|
||||
{
|
||||
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")))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -51,11 +51,11 @@ namespace NadekoBot.Modules.Permissions
|
||||
catch (Exception ex)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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")
|
||||
@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
var arg = e.GetArg("arg");
|
||||
var val = PermissionHelper.ValidateBool(arg);
|
||||
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")
|
||||
@ -77,8 +77,8 @@ namespace NadekoBot.Modules.Permissions
|
||||
{
|
||||
var perms = PermissionsHandler.GetServerPermissions(e.Server);
|
||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||
await e.Channel.SendMessage("No permissions set for this server.");
|
||||
await e.Channel.SendMessage(perms.ToString());
|
||||
await e.Channel.SendMessage("No permissions set for this server.").ConfigureAwait(false);
|
||||
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "roleperms")
|
||||
@ -96,15 +96,15 @@ namespace NadekoBot.Modules.Permissions
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await e.Channel.SendMessage("💢 Error: " + ex.Message);
|
||||
await e.Channel.SendMessage("💢 Error: " + ex.Message).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var perms = PermissionsHandler.GetRolePermissionsById(e.Server, role.Id);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||
await e.Channel.SendMessage($"No permissions set for **{role.Name}** role.");
|
||||
await e.Channel.SendMessage(perms.ToString());
|
||||
await e.Channel.SendMessage($"No permissions set for **{role.Name}** role.").ConfigureAwait(false);
|
||||
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "channelperms")
|
||||
@ -122,14 +122,14 @@ namespace NadekoBot.Modules.Permissions
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await e.Channel.SendMessage("💢 Error: " + ex.Message);
|
||||
await e.Channel.SendMessage("💢 Error: " + ex.Message).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var perms = PermissionsHandler.GetChannelPermissionsById(e.Server, channel.Id);
|
||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||
await e.Channel.SendMessage($"No permissions set for **{channel.Name}** channel.");
|
||||
await e.Channel.SendMessage(perms.ToString());
|
||||
await e.Channel.SendMessage($"No permissions set for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "userperms")
|
||||
@ -146,14 +146,14 @@ namespace NadekoBot.Modules.Permissions
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await e.Channel.SendMessage("💢 Error: " + ex.Message);
|
||||
await e.Channel.SendMessage("💢 Error: " + ex.Message).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var perms = PermissionsHandler.GetUserPermissionsById(e.Server, user.Id);
|
||||
if (string.IsNullOrWhiteSpace(perms?.ToString()))
|
||||
await e.Channel.SendMessage($"No permissions set for user **{user.Name}**.");
|
||||
await e.Channel.SendMessage(perms.ToString());
|
||||
await e.Channel.SendMessage($"No permissions set for user **{user.Name}**.").ConfigureAwait(false);
|
||||
await e.Channel.SendMessage(perms.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "sm").Alias(Prefix + "servermodule")
|
||||
@ -168,15 +168,15 @@ namespace NadekoBot.Modules.Permissions
|
||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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
|
||||
{
|
||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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
|
||||
{
|
||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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
|
||||
{
|
||||
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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
|
||||
{
|
||||
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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"));
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
await e.Channel.SendMessage(exArg.Message);
|
||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||
}
|
||||
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();
|
||||
NadekoBot.Config.UserBlacklist.Add(usr.Id);
|
||||
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")
|
||||
@ -600,13 +600,13 @@ namespace NadekoBot.Modules.Permissions
|
||||
{
|
||||
NadekoBot.Config.UserBlacklist.Remove(usr.Id);
|
||||
ConfigHandler.SaveConfig();
|
||||
await e.Channel.SendMessage($"`Sucessfully unblacklisted user {usr.Name}`");
|
||||
await e.Channel.SendMessage($"`Sucessfully unblacklisted user {usr.Name}`").ConfigureAwait(false);
|
||||
}
|
||||
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")
|
||||
@ -620,8 +620,8 @@ namespace NadekoBot.Modules.Permissions
|
||||
var ch = e.Message.MentionedChannels.First();
|
||||
NadekoBot.Config.UserBlacklist.Add(ch.Id);
|
||||
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")
|
||||
@ -635,8 +635,8 @@ namespace NadekoBot.Modules.Permissions
|
||||
var ch = e.Message.MentionedChannels.First();
|
||||
NadekoBot.Config.UserBlacklist.Remove(ch.Id);
|
||||
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")
|
||||
@ -654,7 +654,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
NadekoBot.Client.FindServers(arg.Trim()).FirstOrDefault();
|
||||
if (server == null)
|
||||
{
|
||||
await e.Channel.SendMessage("Cannot find that server");
|
||||
await e.Channel.SendMessage("Cannot find that server").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var serverId = server.Id;
|
||||
@ -666,8 +666,8 @@ namespace NadekoBot.Modules.Permissions
|
||||
TypingGame 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.Modules;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.DataModels;
|
||||
using NadekoBot.Classes.JSONModels;
|
||||
using NadekoBot.DataModels;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
using System;
|
||||
@ -92,12 +92,12 @@ namespace NadekoBot.Modules.Pokemon
|
||||
var target = e.Server.FindUsers(targetStr).FirstOrDefault();
|
||||
if (target == null)
|
||||
{
|
||||
await e.Channel.SendMessage("No such person.");
|
||||
await e.Channel.SendMessage("No such person.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
//get target stats
|
||||
@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
//If target's HP is below 0, no use attacking
|
||||
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;
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
var enabledMoves = userType.Moves;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
Stats[e.User.Id] = userStats;
|
||||
Stats[target.Id] = targetStats;
|
||||
|
||||
await e.Channel.SendMessage(response);
|
||||
await e.Channel.SendMessage(response).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "ml")
|
||||
@ -206,7 +206,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
{
|
||||
str += $"\n{userType.Icon}{m}";
|
||||
}
|
||||
await e.Channel.SendMessage(str);
|
||||
await e.Channel.SendMessage(str).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "heal")
|
||||
@ -220,7 +220,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
var usr = e.Server.FindUsers(targetStr).FirstOrDefault();
|
||||
if (usr == null)
|
||||
{
|
||||
await e.Channel.SendMessage("No such person.");
|
||||
await e.Channel.SendMessage("No such person.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (Stats.ContainsKey(usr.Id))
|
||||
@ -230,7 +230,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
int HP = targetStats.Hp;
|
||||
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;
|
||||
}
|
||||
//Payment~
|
||||
@ -238,7 +238,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
||||
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;
|
||||
}
|
||||
var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name;
|
||||
@ -249,16 +249,16 @@ namespace NadekoBot.Modules.Pokemon
|
||||
{
|
||||
//Could heal only for half HP?
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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();
|
||||
if (usr == null)
|
||||
{
|
||||
await e.Channel.SendMessage("No such person.");
|
||||
await e.Channel.SendMessage("No such person.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
var pts = DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
||||
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;
|
||||
}
|
||||
FlowersHandler.RemoveFlowers(e.User, $"set usertype to {targetTypeStr}", amount);
|
||||
@ -327,7 +327,7 @@ namespace NadekoBot.Modules.Pokemon
|
||||
|
||||
//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 + "; ";
|
||||
}
|
||||
|
||||
await e.Channel.SendMessage(msg);
|
||||
await e.Channel.SendMessage(msg).ConfigureAwait(false);
|
||||
};
|
||||
|
||||
private Func<CommandEventArgs, Task> ConvertFunc() =>
|
||||
@ -69,7 +69,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
{
|
||||
try
|
||||
{
|
||||
await e.Channel.SendIsTyping();
|
||||
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||
|
||||
string from = e.GetArg("from-to").ToLowerInvariant().Split('>')[0];
|
||||
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 outUnit = inUnit.Convert(toCode);
|
||||
await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString());
|
||||
await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
reInitCurrencyConverterTable();
|
||||
Unit inUnit = currTable.CreateUnit(quantity, from.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)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
champ.ImageStream.Position = 0;
|
||||
await e.Channel.SendFile("champ.png", champ.ImageStream);
|
||||
await e.Channel.SendFile("champ.png", champ.ImageStream).ConfigureAwait(false);
|
||||
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;
|
||||
if (role != null)
|
||||
{
|
||||
@ -103,7 +103,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
{
|
||||
Console.WriteLine("Sending lol image from cache.");
|
||||
champ.ImageStream.Position = 0;
|
||||
await e.Channel.SendFile("champ.png", champ.ImageStream);
|
||||
await e.Channel.SendFile("champ.png", champ.ImageStream).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
//name = data["title"].ToString();
|
||||
@ -134,7 +134,8 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
roles[i] = ">" + roles[i] + "<";
|
||||
}
|
||||
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"];
|
||||
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 };
|
||||
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)
|
||||
{
|
||||
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
|
||||
.GetResponseStringAsync($"http://api.champion.gg/stats/champs/mostBanned?" +
|
||||
$"api_key={NadekoBot.Creds.LOLAPIKey}&page=1&" +
|
||||
$"limit={showCount}"))["data"] as JArray;
|
||||
$"limit={showCount}")
|
||||
.ConfigureAwait(false))["data"] as JArray;
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"**Showing {showCount} top banned champions.**");
|
||||
@ -303,11 +305,11 @@ Assists: {general["assists"]} Ban: {general["banRate"]}%
|
||||
//sb.AppendLine($" ({data[i]["general"]["banRate"]}%)");
|
||||
}
|
||||
|
||||
await e.Channel.SendMessage(sb.ToString());
|
||||
await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
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;
|
||||
try
|
||||
{
|
||||
data = await GetStreamStatus(stream);
|
||||
data = await GetStreamStatus(stream).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
msg += $"\n`Here is the Link:`【 http://www.beam.pro/{stream.Username}/ 】";
|
||||
else if (stream.Type == StreamNotificationConfig.StreamType.YoutubeGaming)
|
||||
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}";
|
||||
if (cachedStatuses.TryGetValue(hitboxUrl, out result))
|
||||
return result;
|
||||
response = await SearchHelper.GetResponseStringAsync(hitboxUrl);
|
||||
response = await SearchHelper.GetResponseStringAsync(hitboxUrl).ConfigureAwait(false);
|
||||
data = JObject.Parse(response);
|
||||
isLive = data["media_is_live"].ToString() == "1";
|
||||
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)}";
|
||||
if (cachedStatuses.TryGetValue(twitchUrl, out result))
|
||||
return result;
|
||||
response = await SearchHelper.GetResponseStringAsync(twitchUrl);
|
||||
response = await SearchHelper.GetResponseStringAsync(twitchUrl).ConfigureAwait(false);
|
||||
data = JObject.Parse(response);
|
||||
isLive = !string.IsNullOrWhiteSpace(data["stream"].ToString());
|
||||
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}";
|
||||
if (cachedStatuses.TryGetValue(beamUrl, out result))
|
||||
return result;
|
||||
response = await SearchHelper.GetResponseStringAsync(beamUrl);
|
||||
response = await SearchHelper.GetResponseStringAsync(beamUrl).ConfigureAwait(false);
|
||||
data = JObject.Parse(response);
|
||||
isLive = data["online"].ToObject<bool>() == true;
|
||||
result = new Tuple<bool, string>(isLive, data["viewersCurrent"].ToString());
|
||||
@ -162,13 +162,13 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
snc.Username.ToLower().Trim() == username);
|
||||
if (toRemove == null)
|
||||
{
|
||||
await e.Channel.SendMessage(":anger: No such stream.");
|
||||
await e.Channel.SendMessage(":anger: No such stream.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
config.ObservingStreams.Remove(toRemove);
|
||||
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")
|
||||
@ -187,7 +187,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ namespace NadekoBot.Modules.Searches.Commands
|
||||
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);
|
||||
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;
|
||||
}
|
||||
Tuple<bool, string> data;
|
||||
try
|
||||
{
|
||||
data = await GetStreamStatus(stream);
|
||||
data = await GetStreamStatus(stream).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await e.Channel.SendMessage(":anger: Stream probably doesn't exist.");
|
||||
await e.Channel.SendMessage(":anger: Stream probably doesn't exist.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
if (!exists)
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Searches
|
||||
{
|
||||
var city = e.GetArg("city").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"];
|
||||
|
||||
@ -57,7 +57,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
📏 **Lat,Long:** ({obj["latitude"]}, {obj["longitude"]}) ☁ **Condition:** {obj["condition"]}
|
||||
😓 **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
|
||||
🌄 **Sunrise:** {obj["sunrise"]} 🌇 **Sunset:** {obj["sunset"]}");
|
||||
🌄 **Sunrise:** {obj["sunrise"]} 🌇 **Sunset:** {obj["sunset"]}").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "yt")
|
||||
@ -65,10 +65,10 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Description("Searches youtubes and shows the first result")
|
||||
.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")));
|
||||
await e.Channel.SendMessage(shortUrl);
|
||||
var shortUrl = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query")).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
await e.Channel.SendMessage(shortUrl).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "ani")
|
||||
@ -77,19 +77,19 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Description("Queries anilist for an anime and shows the first result.")
|
||||
.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;
|
||||
try
|
||||
{
|
||||
result = (await SearchHelper.GetAnimeData(e.GetArg("query"))).ToString();
|
||||
result = (await SearchHelper.GetAnimeData(e.GetArg("query")).ConfigureAwait(false)).ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await e.Channel.SendMessage("Failed to find that anime.");
|
||||
await e.Channel.SendMessage("Failed to find that anime.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await e.Channel.SendMessage(result.ToString());
|
||||
await e.Channel.SendMessage(result.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "imdb")
|
||||
@ -97,8 +97,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Description("Queries imdb for movies or series, show first result.")
|
||||
.Do(async e =>
|
||||
{
|
||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
||||
await e.Channel.SendIsTyping();
|
||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")).ConfigureAwait(false))) return;
|
||||
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||
string result;
|
||||
try
|
||||
{
|
||||
@ -108,11 +108,11 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
}
|
||||
catch
|
||||
{
|
||||
await e.Channel.SendMessage("Failed to find that movie.");
|
||||
await e.Channel.SendMessage("Failed to find that movie.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await e.Channel.SendMessage(result.ToString());
|
||||
await e.Channel.SendMessage(result.ToString()).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "mang")
|
||||
@ -121,18 +121,18 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Description("Queries anilist for a manga and shows the first result.")
|
||||
.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;
|
||||
try
|
||||
{
|
||||
result = (await SearchHelper.GetMangaData(e.GetArg("query"))).ToString();
|
||||
result = (await SearchHelper.GetMangaData(e.GetArg("query")).ConfigureAwait(false)).ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await e.Channel.SendMessage("Failed to find that anime.");
|
||||
await e.Channel.SendMessage("Failed to find that anime.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendMessage(result);
|
||||
await e.Channel.SendMessage(result).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "randomcat")
|
||||
@ -140,7 +140,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Do(async e =>
|
||||
{
|
||||
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")
|
||||
@ -153,12 +154,12 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
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 obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString));
|
||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString());
|
||||
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
||||
}
|
||||
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
|
||||
{
|
||||
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));
|
||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString());
|
||||
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await e.Channel.SendMessage($"💢 {ex.Message}");
|
||||
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
cgb.CreateCommand(Prefix + "lmgtfy")
|
||||
@ -186,7 +187,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Do(async e =>
|
||||
{
|
||||
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")
|
||||
@ -197,12 +199,13 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
var arg = e.GetArg("name");
|
||||
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;
|
||||
}
|
||||
await e.Channel.SendIsTyping();
|
||||
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||
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
|
||||
{
|
||||
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))
|
||||
{
|
||||
images.Add(
|
||||
Image.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString())));
|
||||
Image.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString()).ConfigureAwait(false)));
|
||||
}
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result));
|
||||
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.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`").ConfigureAwait(false);
|
||||
}
|
||||
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");
|
||||
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;
|
||||
}
|
||||
await e.Channel.SendIsTyping();
|
||||
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||
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
|
||||
{
|
||||
var items = JObject.Parse(res);
|
||||
var sb = new System.Text.StringBuilder();
|
||||
sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}");
|
||||
sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}");
|
||||
sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl()}>");
|
||||
sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl().ConfigureAwait(false)}>");
|
||||
await e.Channel.SendMessage(sb.ToString());
|
||||
}
|
||||
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
|
||||
@ -297,24 +301,24 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
var arg = e.GetArg("query");
|
||||
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;
|
||||
}
|
||||
await e.Channel.SendIsTyping();
|
||||
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||
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
|
||||
{
|
||||
var items = JObject.Parse(res);
|
||||
var sb = new System.Text.StringBuilder();
|
||||
sb.AppendLine($"`Hashtag:` {items["defs"]["def"]["hashtag"].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());
|
||||
}
|
||||
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 =>
|
||||
{
|
||||
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")
|
||||
.Description("Shows a random catfact from <http://catfacts-api.appspot.com/api/facts>")
|
||||
.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)
|
||||
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")
|
||||
@ -341,8 +345,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Description("Shows a random joke from <http://api.yomomma.info/>")
|
||||
.Do(async e =>
|
||||
{
|
||||
var response = await SearchHelper.GetResponseStringAsync("http://api.yomomma.info/");
|
||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆");
|
||||
var response = await SearchHelper.GetResponseStringAsync("http://api.yomomma.info/").ConfigureAwait(false);
|
||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "randjoke")
|
||||
@ -350,8 +354,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
.Description("Shows a random joke from <http://tambal.azurewebsites.net/joke/random>")
|
||||
.Do(async e =>
|
||||
{
|
||||
var response = await SearchHelper.GetResponseStringAsync("http://tambal.azurewebsites.net/joke/random");
|
||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆");
|
||||
var response = await SearchHelper.GetResponseStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false);
|
||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["joke"].ToString() + "` 😆").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
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>")
|
||||
.Do(async e =>
|
||||
{
|
||||
var response = await SearchHelper.GetResponseStringAsync("http://api.icndb.com/jokes/random/");
|
||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["value"]["joke"].ToString() + "` 😆");
|
||||
var response = await SearchHelper.GetResponseStringAsync("http://api.icndb.com/jokes/random/").ConfigureAwait(false);
|
||||
await e.Channel.SendMessage("`" + JObject.Parse(response)["value"]["joke"].ToString() + "` 😆").ConfigureAwait(false);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Prefix + "mi")
|
||||
@ -371,7 +375,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
var magicItems = JsonConvert.DeserializeObject<List<MagicItem>>(File.ReadAllText("data/magicitems.json"));
|
||||
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")
|
||||
@ -388,7 +392,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
|
||||
if (usr == null || string.IsNullOrWhiteSpace(usr.AvatarUrl))
|
||||
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
|
||||
{
|
||||
await e.Channel.SendIsTyping();
|
||||
await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||
string from = e.GetArg("langs").ToLowerInvariant().Split('>')[0];
|
||||
string to = e.GetArg("langs").ToLowerInvariant().Split('>')[1];
|
||||
|
||||
string translation = t.Translate(e.GetArg("text"), from, to);
|
||||
await e.Channel.SendMessage(translation);
|
||||
await e.Channel.SendMessage(translation).ConfigureAwait(false);
|
||||
}
|
||||
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 + ";";
|
||||
}
|
||||
}
|
||||
await e.Channel.SendMessage(ret);
|
||||
await e.Channel.SendMessage(ret).ConfigureAwait(false);
|
||||
}
|
||||
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)))
|
||||
{
|
||||
await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString());
|
||||
await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
last5ActionIDs.Clear();
|
||||
last5ActionIDs.AddRange(cur5ActionsArray.Select(a => a.Id));
|
||||
@ -74,10 +74,11 @@ namespace NadekoBot.Modules.Trello
|
||||
.Parameter("code", Discord.Commands.ParameterType.Required)
|
||||
.Do(async e =>
|
||||
{
|
||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
if (!NadekoBot.IsOwner(e.User.Id) || NadekoBot.IsBot) return;
|
||||
try
|
||||
{
|
||||
await (await client.GetInvite(e.GetArg("code"))).Accept();
|
||||
await (await client.GetInvite(e.GetArg("code")).ConfigureAwait(false)).Accept()
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -117,7 +118,7 @@ namespace NadekoBot.Modules.Trello
|
||||
t.Stop();
|
||||
bound = 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 (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")
|
||||
@ -149,9 +151,11 @@ namespace NadekoBot.Modules.Trello
|
||||
|
||||
|
||||
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
|
||||
await e.Channel.SendMessage("No such list.");
|
||||
await e.Channel.SendMessage("No such list.")
|
||||
.ConfigureAwait(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ namespace NadekoBot
|
||||
return;
|
||||
try
|
||||
{
|
||||
await e.Channel.SendMessage(e.Exception.Message);
|
||||
await e.Channel.SendMessage(e.Exception.Message).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@ -192,10 +192,10 @@ namespace NadekoBot
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Creds.Token))
|
||||
await Client.Connect(Creds.Username, Creds.Password);
|
||||
await Client.Connect(Creds.Username, Creds.Password).ConfigureAwait(false);
|
||||
else
|
||||
{
|
||||
await Client.Connect(Creds.Token);
|
||||
await Client.Connect(Creds.Token).ConfigureAwait(false);
|
||||
IsBot = true;
|
||||
}
|
||||
Console.WriteLine(NadekoBot.Client.CurrentUser.Id);
|
||||
@ -211,14 +211,14 @@ namespace NadekoBot
|
||||
return;
|
||||
}
|
||||
|
||||
//await Task.Delay(90000);
|
||||
await Task.Delay(90000).ConfigureAwait(false);
|
||||
Console.WriteLine("-----------------");
|
||||
Console.WriteLine(await NadekoStats.Instance.GetStats());
|
||||
Console.WriteLine(await NadekoStats.Instance.GetStats().ConfigureAwait(false));
|
||||
Console.WriteLine("-----------------");
|
||||
|
||||
try
|
||||
{
|
||||
OwnerPrivateChannel = await Client.CreatePrivateChannel(Creds.OwnerIds[0]);
|
||||
OwnerPrivateChannel = await Client.CreatePrivateChannel(Creds.OwnerIds[0]).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -245,7 +245,7 @@ namespace NadekoBot
|
||||
public async Task SendMessageToOwner(string message)
|
||||
{
|
||||
if (Config.ForwardMessages && OwnerPrivateChannel != null)
|
||||
await OwnerPrivateChannel.SendMessage(message);
|
||||
await OwnerPrivateChannel.SendMessage(message).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static bool repliedRecently = false;
|
||||
@ -262,29 +262,29 @@ namespace NadekoBot
|
||||
{
|
||||
try
|
||||
{
|
||||
await (await Client.GetInvite(e.Message.Text)).Accept();
|
||||
await e.Channel.SendMessage("I got in!");
|
||||
await (await Client.GetInvite(e.Message.Text).ConfigureAwait(false)).Accept().ConfigureAwait(false);
|
||||
await e.Channel.SendMessage("I got in!").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (e.User.Id == 109338686889476096)
|
||||
{ //carbonitex invite
|
||||
await e.Channel.SendMessage("Failed to join the server.");
|
||||
await e.Channel.SendMessage("Failed to join the server.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
repliedRecently = true;
|
||||
if (e.Message.RawText != "-h")
|
||||
await e.Channel.SendMessage(HelpCommand.DMHelpString);
|
||||
await Task.Delay(2000);
|
||||
await e.Channel.SendMessage(HelpCommand.DMHelpString).ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
repliedRecently = false;
|
||||
}
|
||||
catch { }
|
||||
|
@ -471,7 +471,6 @@
|
||||
<ItemGroup>
|
||||
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
|
Loading…
Reference in New Issue
Block a user