Animal racing done, more mass replacements

This commit is contained in:
Kwoth 2016-08-20 17:02:33 +02:00
parent 43c9e7d04d
commit acebc6e914
15 changed files with 287 additions and 289 deletions

View File

@ -23,7 +23,7 @@ namespace NadekoBot.Classes
var flows = amount + " " + NadekoBot.Config.CurrencySign; var flows = amount + " " + NadekoBot.Config.CurrencySign;
await u.SendMessage("👑Congratulations!👑\nYou received: " + flows).ConfigureAwait(false); await u.SendMessageAsync("👑Congratulations!👑\nYou received: " + flows).ConfigureAwait(false);
} }
public static async Task<bool> RemoveFlowers(Discord.User u, string reason, int amount, bool silent=false, string message="👎`Bot owner has taken {0}{1} from you.`") public static async Task<bool> RemoveFlowers(Discord.User u, string reason, int amount, bool silent=false, string message="👎`Bot owner has taken {0}{1} from you.`")
@ -46,7 +46,7 @@ namespace NadekoBot.Classes
if (silent) if (silent)
return true; return true;
await u.SendMessage(string.Format(message,amount,NadekoBot.Config.CurrencySign)).ConfigureAwait(false); await u.SendMessageAsync(string.Format(message,amount,NadekoBot.Config.CurrencySign)).ConfigureAwait(false);
return true; return true;
} }
} }

View File

@ -543,7 +543,7 @@ namespace NadekoBot.Modules.Administration
// { // {
// return; // return;
// } // }
// await channel.SendMessage(msg); // await channel.SendMessageAsync(msg);
// } // }
// else if (ids[1].ToUpperInvariant().StartsWith("U:")) // else if (ids[1].ToUpperInvariant().StartsWith("U:"))
// { // {
@ -553,7 +553,7 @@ namespace NadekoBot.Modules.Administration
// { // {
// return; // return;
// } // }
// await user.SendMessage(msg); // await user.SendMessageAsync(msg);
// } // }
// else // else
// { // {

View File

@ -26,7 +26,7 @@
// continue; // continue;
// foreach (var chan in set.Except(new[] { e.Channel })) // foreach (var chan in set.Except(new[] { e.Channel }))
// { // {
// await chan.SendMessage(GetText(e.Server, e.Channel, imsg.Author, e.Message)).ConfigureAwait(false); // await chan.SendMessageAsync(GetText(e.Server, e.Channel, imsg.Author, e.Message)).ConfigureAwait(false);
// } // }
// } // }
// } // }
@ -75,7 +75,7 @@
// if (Subscribers.TryAdd(token, set)) // if (Subscribers.TryAdd(token, set))
// { // {
// set.Add(e.Channel); // set.Add(e.Channel);
// await imsg.Author.SendMessage("This is your CSC token:" + token.ToString()).ConfigureAwait(false); // await imsg.Author.SendMessageAsync("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
// } // }
// }); // });

View File

@ -23,7 +23,7 @@
// var incs = DbHandler.Instance.FindAll<Incident>(i => i.ServerId == sid && i.Read == false); // var incs = DbHandler.Instance.FindAll<Incident>(i => i.ServerId == sid && i.Read == false);
// DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return i; })); // DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return i; }));
// await imsg.Author.SendMessage(string.Join("\n----------------------", incs.Select(i => i.Text))); // await imsg.Author.SendMessageAsync(string.Join("\n----------------------", incs.Select(i => i.Text)));
// }); // });
// cgb.CreateCommand(Module.Prefix + "listallincidents") // cgb.CreateCommand(Module.Prefix + "listallincidents")

View File

@ -45,7 +45,7 @@
// if (usr?.Status != UserStatus.Offline) // if (usr?.Status != UserStatus.Offline)
// return; // return;
// await channel.SendMessageAsync($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false); // await channel.SendMessageAsync($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false);
// await usr.SendMessage( // await usr.SendMessageAsync(
// $"User `{imsg.Author.Username}` mentioned you on " + // $"User `{imsg.Author.Username}` mentioned you on " +
// $"`{e.Server.Name}` server while you were offline.\n" + // $"`{e.Server.Name}` server while you were offline.\n" +
// $"`Message:` {e.Message.Text}").ConfigureAwait(false); // $"`Message:` {e.Message.Text}").ConfigureAwait(false);
@ -76,7 +76,7 @@
// //send merged messages to each channel // //send merged messages to each channel
// foreach (var k in toSend) // foreach (var k in toSend)
// { // {
// try { await k.Key.SendMessage(Environment.NewLine + k.Value).ConfigureAwait(false); } catch { } // try { await k.Key.SendMessageAsync(Environment.NewLine + k.Value).ConfigureAwait(false); } catch { }
// } // }
// await Task.Delay(5000); // await Task.Delay(5000);
@ -96,10 +96,10 @@
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// if (e.Before.Name != e.After.Name) // if (e.Before.Name != e.After.Name)
// await ch.SendMessage($@"`{prettyCurrentTime}` **Channel Name Changed** `#{e.Before.Name}` (*{e.After.Id}*) // await ch.SendMessageAsync($@"`{prettyCurrentTime}` **Channel Name Changed** `#{e.Before.Name}` (*{e.After.Id}*)
// `New:` {e.After.Name}").ConfigureAwait(false); // `New:` {e.After.Name}").ConfigureAwait(false);
// else if (e.Before.Topic != e.After.Topic) // else if (e.Before.Topic != e.After.Topic)
// await ch.SendMessage($@"`{prettyCurrentTime}` **Channel Topic Changed** `#{e.After.Name}` (*{e.After.Id}*) // await ch.SendMessageAsync($@"`{prettyCurrentTime}` **Channel Topic Changed** `#{e.After.Name}` (*{e.After.Id}*)
// `Old:` {e.Before.Topic} // `Old:` {e.Before.Topic}
// `New:` {e.After.Topic}").ConfigureAwait(false); // `New:` {e.After.Topic}").ConfigureAwait(false);
// } // }
@ -117,7 +117,7 @@
// Channel ch; // Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// await ch.SendMessage($"❗`{prettyCurrentTime}`❗`Channel Deleted:` #{e.Channel.Name} (*{e.Channel.Id}*)").ConfigureAwait(false); // await ch.SendMessageAsync($"❗`{prettyCurrentTime}`❗`Channel Deleted:` #{e.Channel.Name} (*{e.Channel.Id}*)").ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }
@ -133,7 +133,7 @@
// Channel ch; // Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// await ch.SendMessage($"`{prettyCurrentTime}`🆕`Channel Created:` #{e.Channel.Mention} (*{e.Channel.Id}*)").ConfigureAwait(false); // await ch.SendMessageAsync($"`{prettyCurrentTime}`🆕`Channel Created:` #{e.Channel.Mention} (*{e.Channel.Id}*)").ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }
@ -148,7 +148,7 @@
// Channel ch; // Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// await ch.SendMessage($"`{prettyCurrentTime}`♻`User was unbanned:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false); // await ch.SendMessageAsync($"`{prettyCurrentTime}`♻`User was unbanned:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }
@ -163,7 +163,7 @@
// Channel ch; // Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// await ch.SendMessage($"`{prettyCurrentTime}`✅`User joined:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false); // await ch.SendMessageAsync($"`{prettyCurrentTime}`✅`User joined:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }
@ -178,7 +178,7 @@
// Channel ch; // Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// await ch.SendMessage($"`{prettyCurrentTime}`❗`User left:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false); // await ch.SendMessageAsync($"`{prettyCurrentTime}`❗`User left:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }
@ -193,7 +193,7 @@
// Channel ch; // Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// await ch.SendMessage($"❗`{prettyCurrentTime}`❌`User banned:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false); // await ch.SendMessageAsync($"❗`{prettyCurrentTime}`❌`User banned:` **{imsg.Author.Username}** ({imsg.Author.Id})").ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }
@ -213,13 +213,13 @@
// return; // return;
// if (!string.IsNullOrWhiteSpace(e.Message.Text)) // if (!string.IsNullOrWhiteSpace(e.Message.Text))
// { // {
// await ch.SendMessage( // await ch.SendMessageAsync(
// $@"🕔`{prettyCurrentTime}` **New Message** `#{e.Channel.Name}` // $@"🕔`{prettyCurrentTime}` **New Message** `#{e.Channel.Name}`
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false); //👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
// } // }
// else // else
// { // {
// await ch.SendMessage( // await ch.SendMessageAsync(
// $@"🕔`{prettyCurrentTime}` **File Uploaded** `#{e.Channel.Name}` // $@"🕔`{prettyCurrentTime}` **File Uploaded** `#{e.Channel.Name}`
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false); //👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
// } // }
@ -242,13 +242,13 @@
// return; // return;
// if (!string.IsNullOrWhiteSpace(e.Message.Text)) // if (!string.IsNullOrWhiteSpace(e.Message.Text))
// { // {
// await ch.SendMessage( // await ch.SendMessageAsync(
// $@"🕔`{prettyCurrentTime}` **Message** 🚮 `#{e.Channel.Name}` // $@"🕔`{prettyCurrentTime}` **Message** 🚮 `#{e.Channel.Name}`
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false); //👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
// } // }
// else // else
// { // {
// await ch.SendMessage( // await ch.SendMessageAsync(
// $@"🕔`{prettyCurrentTime}` **File Deleted** `#{e.Channel.Name}` // $@"🕔`{prettyCurrentTime}` **File Deleted** `#{e.Channel.Name}`
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false); //👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
// } // }
@ -268,7 +268,7 @@
// Channel ch; // Channel ch;
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null) // if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
// return; // return;
// await ch.SendMessage( // await ch.SendMessageAsync(
// $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}` // $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}`
//👤`{imsg.Author?.ToString() ?? ("NULL")}` //👤`{imsg.Author?.ToString() ?? ("NULL")}`
// `Old:` {e.Before.Text.Unmention()} // `Old:` {e.Before.Text.Unmention()}
@ -318,15 +318,15 @@
// } // }
// if ((notifyLeave && notifyJoin) && (notifyChAfter == notifyChBefore)) // if ((notifyLeave && notifyJoin) && (notifyChAfter == notifyChBefore))
// { // {
// await notifyChAfter.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} moved from **{beforeVch.Mention}** to **{afterVch.Mention}** voice channel.").ConfigureAwait(false); // await notifyChAfter.SendMessageAsync($"🎼`{prettyCurrentTime}` {e.Before.Name} moved from **{beforeVch.Mention}** to **{afterVch.Mention}** voice channel.").ConfigureAwait(false);
// } // }
// else if (notifyJoin) // else if (notifyJoin)
// { // {
// await notifyChAfter.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} has joined **{afterVch.Mention}** voice channel.").ConfigureAwait(false); // await notifyChAfter.SendMessageAsync($"🎼`{prettyCurrentTime}` {e.Before.Name} has joined **{afterVch.Mention}** voice channel.").ConfigureAwait(false);
// } // }
// else if (notifyLeave) // else if (notifyLeave)
// { // {
// await notifyChBefore.SendMessage($"🎼`{prettyCurrentTime}` {e.Before.Name} has left **{beforeVch.Mention}** voice channel.").ConfigureAwait(false); // await notifyChBefore.SendMessageAsync($"🎼`{prettyCurrentTime}` {e.Before.Name} has left **{beforeVch.Mention}** voice channel.").ConfigureAwait(false);
// } // }
// } // }
// } // }
@ -368,7 +368,7 @@
// } // }
// else // else
// return; // return;
// await ch.SendMessage(str).ConfigureAwait(false); // await ch.SendMessageAsync(str).ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }

View File

@ -47,7 +47,7 @@
// catch { } // catch { }
// try // try
// { // {
// lastMessage = await ch.SendMessage(msg).ConfigureAwait(false); // lastMessage = await ch.SendMessageAsync(msg).ConfigureAwait(false);
// } // }
// catch { } // catch { }
// } // }

View File

@ -48,7 +48,7 @@
// Greeted++; // Greeted++;
// try // try
// { // {
// await imsg.Author.SendMessage($"`Farewell Message From {e.Server?.Name}`\n" + msg).ConfigureAwait(false); // await imsg.Author.SendMessageAsync($"`Farewell Message From {e.Server?.Name}`\n" + msg).ConfigureAwait(false);
// } // }
// catch { } // catch { }
@ -57,7 +57,7 @@
// { // {
// if (channel == null) return; // if (channel == null) return;
// Greeted++; // Greeted++;
// var toDelete = await channel.SendMessage(msg).ConfigureAwait(false); // var toDelete = await channel.SendMessageAsync(msg).ConfigureAwait(false);
// if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages) // if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages)
// { // {
// await Task.Delay(30000).ConfigureAwait(false); // 5 minutes // await Task.Delay(30000).ConfigureAwait(false); // 5 minutes
@ -84,13 +84,13 @@
// if (controls.GreetPM) // if (controls.GreetPM)
// { // {
// Greeted++; // Greeted++;
// await imsg.Author.SendMessage($"`Welcome Message From {e.Server.Name}`\n" + msg).ConfigureAwait(false); // await imsg.Author.SendMessageAsync($"`Welcome Message From {e.Server.Name}`\n" + msg).ConfigureAwait(false);
// } // }
// else // else
// { // {
// if (channel == null) return; // if (channel == null) return;
// Greeted++; // Greeted++;
// var toDelete = await channel.SendMessage(msg).ConfigureAwait(false); // var toDelete = await channel.SendMessageAsync(msg).ConfigureAwait(false);
// if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages) // if (e.Server.CurrentUser.GetPermissions(channel).ManageMessages && controls.DeleteGreetMessages)
// { // {
// await Task.Delay(30000).ConfigureAwait(false); // 5 minutes // await Task.Delay(30000).ConfigureAwait(false); // 5 minutes

View File

@ -37,7 +37,7 @@
// try // try
// { // {
// await e.Server.Owner.SendMessage( // await e.Server.Owner.SendMessageAsync(
// "I don't have manage server and/or Manage Channels permission," + // "I don't have manage server and/or Manage Channels permission," +
// $" so I cannot run voice+text on **{e.Server.Name}** server.").ConfigureAwait(false); // $" so I cannot run voice+text on **{e.Server.Name}** server.").ConfigureAwait(false);
// } // }

View File

@ -1,5 +1,6 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes;
using NadekoBot.Classes; using NadekoBot.Classes;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using System; using System;
@ -11,60 +12,53 @@ using System.Threading.Tasks;
namespace NadekoBot.Modules.Gambling.Commands namespace NadekoBot.Modules.Gambling.Commands
{ {
public partial class Gambling
{
[Group] [Group]
class AnimalRacing public class AnimalRacing
{ {
public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces = new ConcurrentDictionary<ulong, AnimalRace>(); public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces = new ConcurrentDictionary<ulong, AnimalRace>();
public AnimalRacing(DiscordModule module) : base(module) [LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task Race(IMessage imsg)
{ {
} var channel = imsg.Channel as ITextChannel;
var ar = new AnimalRace(channel.Guild.Id, channel);
internal override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand(Prefix + "race")
.Description($"Starts a new animal race. | `{Prefix}race`")
.Do(e =>
{
var ar = new AnimalRace(e.Server.Id, e.Channel);
if (ar.Fail) if (ar.Fail)
{ await channel.SendMessageAsync("🏁 `Failed starting a race. Another race is probably running.`");
return;
} }
});
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
cgb.CreateCommand(Prefix + "joinrace") [RequireContext(ContextType.Guild)]
.Alias(Prefix + "jr") public async Task JoinRace(IMessage imsg, int amount = 0)
.Description($"Joins a new race. You can specify an amount of flowers for betting (optional). You will get YourBet*(participants-1) back if you win. | `{Prefix}jr` or `{Prefix}jr 5`")
.Parameter("amount", ParameterType.Optional)
.Do(async e =>
{ {
var channel = imsg.Channel as ITextChannel;
int amount; if (amount < 0)
if (!int.TryParse(e.GetArg("amount"), out amount) || amount < 0)
amount = 0; amount = 0;
var userFlowers = Gambling.GetUserFlowers(imsg.Author.Id); //todo DB
//var userFlowers = Gambling.GetUserFlowers(imsg.Author.Id);
if (userFlowers < amount) //if (userFlowers < amount)
{ //{
await channel.SendMessageAsync($"{imsg.Author.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false); // await channel.SendMessageAsync($"{imsg.Author.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
return; // return;
} //}
if (amount > 0) //if (amount > 0)
await FlowersHandler.RemoveFlowers(imsg.Author, "BetRace", (int)amount, true).ConfigureAwait(false); // await FlowersHandler.RemoveFlowers(imsg.Author, "BetRace", (int)amount, true).ConfigureAwait(false);
AnimalRace ar; AnimalRace ar;
if (!AnimalRaces.TryGetValue(e.Server.Id, out ar)) if (!AnimalRaces.TryGetValue(channel.Guild.Id, out ar))
{ {
await channel.SendMessageAsync("No race exists on this server"); await channel.SendMessageAsync("No race exists on this server");
return; return;
} }
await ar.JoinRace(imsg.Author, amount); await ar.JoinRace(imsg.Author as IGuildUser, amount);
});
} }
public class AnimalRace public class AnimalRace
@ -78,10 +72,10 @@ namespace NadekoBot.Modules.Gambling.Commands
private ulong serverId; private ulong serverId;
private int messagesSinceGameStarted = 0; private int messagesSinceGameStarted = 0;
public IGuildChannel raceChannel { get; set; } public ITextChannel raceChannel { get; set; }
public bool Started { get; private set; } = false; public bool Started { get; private set; } = false;
public AnimalRace(ulong serverId, Channel ch) public AnimalRace(ulong serverId, ITextChannel ch)
{ {
this.serverId = serverId; this.serverId = serverId;
this.raceChannel = ch; this.raceChannel = ch;
@ -97,24 +91,26 @@ namespace NadekoBot.Modules.Gambling.Commands
{ {
try try
{ {
await raceChannel.SendMessage($"🏁`Race is starting in 20 seconds or when the room is full. Type {NadekoBot.Config.CommandPrefixes.Gambling}jr to join the race.`"); //todo Commmand prefixes from config
await raceChannel.SendMessageAsync($"🏁`Race is starting in 20 seconds or when the room is full. Type $jr to join the race.`");
var t = await Task.WhenAny(Task.Delay(20000, token), fullgame); var t = await Task.WhenAny(Task.Delay(20000, token), fullgame);
Started = true; Started = true;
cancelSource.Cancel(); cancelSource.Cancel();
if (t == fullgame) if (t == fullgame)
{ {
await raceChannel.SendMessage("🏁`Race full, starting right now!`"); await raceChannel.SendMessageAsync("🏁`Race full, starting right now!`");
} }
else if (participants.Count > 1) else if (participants.Count > 1)
{ {
await raceChannel.SendMessage("🏁`Game starting with " + participants.Count + " participants.`"); await raceChannel.SendMessageAsync("🏁`Game starting with " + participants.Count + " participants.`");
} }
else else
{ {
await raceChannel.SendMessage("🏁`Race failed to start since there was not enough participants.`"); await raceChannel.SendMessageAsync("🏁`Race failed to start since there was not enough participants.`");
var p = participants.FirstOrDefault(); var p = participants.FirstOrDefault();
if (p != null) //todo DB
await FlowersHandler.AddFlowersAsync(p.User, "BetRace", p.AmountBet, true).ConfigureAwait(false); //if (p != null)
// await FlowersHandler.AddFlowersAsync(p.User, "BetRace", p.AmountBet, true).ConfigureAwait(false);
End(); End();
return; return;
} }
@ -169,12 +165,12 @@ namespace NadekoBot.Modules.Gambling.Commands
if (msg == null || messagesSinceGameStarted >= 10) // also resend the message if channel was spammed if (msg == null || messagesSinceGameStarted >= 10) // also resend the message if channel was spammed
{ {
if (msg != null) if (msg != null)
try { await msg.Delete(); } catch { } try { await msg.DeleteAsync(); } catch { }
msg = await raceChannel.SendMessage(text); msg = await raceChannel.SendMessageAsync(text).ConfigureAwait(false);
messagesSinceGameStarted = 0; messagesSinceGameStarted = 0;
} }
else else
await msg.Edit(text); await msg.ModifyAsync(m => m.Content = text).ConfigureAwait(false);
await Task.Delay(2500); await Task.Delay(2500);
} }
@ -187,19 +183,20 @@ namespace NadekoBot.Modules.Gambling.Commands
if (winner.AmountBet > 0) if (winner.AmountBet > 0)
{ {
var wonAmount = winner.AmountBet * (participants.Count - 1); var wonAmount = winner.AmountBet * (participants.Count - 1);
await FlowersHandler.AddFlowersAsync(winner.User, "Won a Race", wonAmount).ConfigureAwait(false); //todo DB
await raceChannel.SendMessage($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race and {wonAmount}{NadekoBot.Config.CurrencySign}!**"); //await FlowersHandler.AddFlowersAsync(winner.User, "Won a Race", wonAmount).ConfigureAwait(false);
await raceChannel.SendMessageAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race and {wonAmount}{NadekoBot.Config.Currency.Sign}!**").ConfigureAwait(false);
} }
else else
{ {
await raceChannel.SendMessage($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race!**"); await raceChannel.SendMessageAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race!**");
} }
} }
private void Client_MessageReceived(IMessage imsg) private async Task Client_MessageReceived(IMessage imsg)
{ {
if (e.Message.IsAuthor || e.Channel.IsPrivate || e.Channel != raceChannel) if (await imsg.IsAuthor(NadekoBot.Client) || !(imsg.Channel is ITextChannel) || imsg.Channel != raceChannel)
return; return;
messagesSinceGameStarted++; messagesSinceGameStarted++;
} }
@ -217,22 +214,22 @@ namespace NadekoBot.Modules.Gambling.Commands
var animal = ""; var animal = "";
if (!animals.TryDequeue(out animal)) if (!animals.TryDequeue(out animal))
{ {
await raceChannel.SendMessage($"{u.Mention} `There is no running race on this server.`"); await raceChannel.SendMessageAsync($"{u.Mention} `There is no running race on this server.`");
return false; return false;
} }
var p = new Participant(u, animal, amount); var p = new Participant(u, animal, amount);
if (participants.Contains(p)) if (participants.Contains(p))
{ {
await raceChannel.SendMessage($"{u.Mention} `You already joined this race.`"); await raceChannel.SendMessageAsync($"{u.Mention} `You already joined this race.`");
return false; return false;
} }
if (Started) if (Started)
{ {
await raceChannel.SendMessage($"{u.Mention} `Race is already started`"); await raceChannel.SendMessageAsync($"{u.Mention} `Race is already started`");
return false; return false;
} }
participants.Add(p); participants.Add(p);
await raceChannel.SendMessage($"{u.Mention} **joined the race as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {NadekoBot.Config.CurrencyName.SnPl(amount)}!**" : "**")); await raceChannel.SendMessageAsync($"{u.Mention} **joined the race as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {(amount == 1? NadekoBot.Config.Currency.Name: NadekoBot.Config.Currency.PluralName)}!**" : "**"));
return true; return true;
} }
} }
@ -293,4 +290,5 @@ namespace NadekoBot.Modules.Gambling.Commands
} }
} }
} }
}
} }

View File

@ -69,10 +69,10 @@
// IsActive = true; // IsActive = true;
// CurrentSentence = SentencesProvider.GetRandomSentence(); // CurrentSentence = SentencesProvider.GetRandomSentence();
// var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f); // var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f);
// await channel.SendMessage($":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false); // await channel.SendMessageAsync($":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**...").ConfigureAwait(false); // var msg = await channel.SendMessageAsync("Starting new typing contest in **3**...").ConfigureAwait(false);
// await Task.Delay(1000).ConfigureAwait(false); // await Task.Delay(1000).ConfigureAwait(false);
// await msg.Edit("Starting new typing contest in **2**...").ConfigureAwait(false); // await msg.Edit("Starting new typing contest in **2**...").ConfigureAwait(false);
// await Task.Delay(1000).ConfigureAwait(false); // await Task.Delay(1000).ConfigureAwait(false);

View File

@ -63,7 +63,7 @@
// msg += $"\n`Here is the Link:`【 http://www.beam.pro/{stream.Username}/ 】"; // msg += $"\n`Here is the Link:`【 http://www.beam.pro/{stream.Username}/ 】";
// else if (stream.Type == StreamNotificationConfig.StreamType.YoutubeGaming) // else if (stream.Type == StreamNotificationConfig.StreamType.YoutubeGaming)
// msg += $"\n`Here is the Link:`【 not implemented yet - {stream.Username} 】"; // msg += $"\n`Here is the Link:`【 not implemented yet - {stream.Username} 】";
// await channel.SendMessage(msg).ConfigureAwait(false); // await channel.SendMessageAsync(msg).ConfigureAwait(false);
// } // }
// } // }
// FirstPass = false; // FirstPass = false;

View File

@ -61,7 +61,7 @@
// if (ch == null) // if (ch == null)
// return; // return;
// await ch.SendMessage( // await ch.SendMessageAsync(
// replacements.Aggregate(NadekoBot.Config.RemindMessageFormat, // replacements.Aggregate(NadekoBot.Config.RemindMessageFormat,
// (cur, replace) => cur.Replace(replace.Key, replace.Value(r))) // (cur, replace) => cur.Replace(replace.Key, replace.Value(r)))
// ).ConfigureAwait(false); //it works trust me // ).ConfigureAwait(false); //it works trust me

View File

@ -633,7 +633,7 @@ namespace NadekoBot.Modules.Music
var textCh = e.Channel; var textCh = e.Channel;
if (voiceCh == null || voiceCh.Server != textCh.Server) if (voiceCh == null || voiceCh.Server != textCh.Server)
{ {
await textCh.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false); await textCh.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false);
return; return;
} }
var name = e.GetArg("name")?.Trim().ToLowerInvariant(); var name = e.GetArg("name")?.Trim().ToLowerInvariant();
@ -812,7 +812,7 @@ namespace NadekoBot.Modules.Music
if (voiceCh == null || voiceCh.Server != textCh.Server) if (voiceCh == null || voiceCh.Server != textCh.Server)
{ {
if (!silent) if (!silent)
await textCh.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false); await textCh.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false);
throw new ArgumentNullException(nameof(voiceCh)); throw new ArgumentNullException(nameof(voiceCh));
} }
if (string.IsNullOrWhiteSpace(query) || query.Length < 3) if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
@ -836,7 +836,7 @@ namespace NadekoBot.Modules.Music
await lastFinishedMessage.Delete().ConfigureAwait(false); await lastFinishedMessage.Delete().ConfigureAwait(false);
if (playingMessage != null) if (playingMessage != null)
await playingMessage.Delete().ConfigureAwait(false); await playingMessage.Delete().ConfigureAwait(false);
lastFinishedMessage = await textCh.SendMessage($"🎵`Finished`{song.PrettyName}").ConfigureAwait(false); lastFinishedMessage = await textCh.SendMessageAsync($"🎵`Finished`{song.PrettyName}").ConfigureAwait(false);
if (mp.Autoplay && mp.Playlist.Count == 0 && song.SongInfo.Provider == "YouTube") if (mp.Autoplay && mp.Playlist.Count == 0 && song.SongInfo.Provider == "YouTube")
{ {
await QueueSong(queuer.Server.CurrentUser, textCh, voiceCh, (await SearchHelper.GetRelatedVideoIds(song.SongInfo.Query, 4)).ToList().Shuffle().FirstOrDefault(), silent, musicType).ConfigureAwait(false); await QueueSong(queuer.Server.CurrentUser, textCh, voiceCh, (await SearchHelper.GetRelatedVideoIds(song.SongInfo.Query, 4)).ToList().Shuffle().FirstOrDefault(), silent, musicType).ConfigureAwait(false);
@ -860,7 +860,7 @@ namespace NadekoBot.Modules.Music
{ {
var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(sender.Volume * 100)}%`"; var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(sender.Volume * 100)}%`";
playingMessage = await textCh.SendMessage(msgTxt).ConfigureAwait(false); playingMessage = await textCh.SendMessageAsync(msgTxt).ConfigureAwait(false);
} }
catch { } catch { }
} }
@ -877,12 +877,12 @@ namespace NadekoBot.Modules.Music
} }
catch (PlaylistFullException) catch (PlaylistFullException)
{ {
await textCh.SendMessage($"🎵 `Queue is full at {musicPlayer.MaxQueueSize}/{musicPlayer.MaxQueueSize}.` "); await textCh.SendMessageAsync($"🎵 `Queue is full at {musicPlayer.MaxQueueSize}/{musicPlayer.MaxQueueSize}.` ");
throw; throw;
} }
if (!silent) if (!silent)
{ {
var queuedMessage = await textCh.SendMessage($"🎵`Queued`{resolvedSong.PrettyName} **at** `#{musicPlayer.Playlist.Count + 1}`").ConfigureAwait(false); var queuedMessage = await textCh.SendMessageAsync($"🎵`Queued`{resolvedSong.PrettyName} **at** `#{musicPlayer.Playlist.Count + 1}`").ConfigureAwait(false);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Task.Run(async () => Task.Run(async () =>
{ {

View File

@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Permissions.Commands
$"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel.\n" + $"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel.\n" +
$"`Full message:` {args.Message.Text}"); $"`Full message:` {args.Message.Text}");
if (serverPerms.Verbose) if (serverPerms.Verbose)
await args.Channel.SendMessage($"{args.User.Mention} Invite links are not " + await args.Channel.SendMessageAsync($"{args.User.Mention} Invite links are not " +
$"allowed on this channel.") $"allowed on this channel.")
.ConfigureAwait(false); .ConfigureAwait(false);
} }

View File

@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Permissions.Commands
$"BANNED WORD in [{args.Channel.Name}/{args.Channel.Id}] channel.\n" + $"BANNED WORD in [{args.Channel.Name}/{args.Channel.Id}] channel.\n" +
$"`Full message:` {args.Message.Text}"); $"`Full message:` {args.Message.Text}");
if (serverPerms.Verbose) if (serverPerms.Verbose)
await args.Channel.SendMessage($"{args.User.Mention} One or more of the words you used " + await args.Channel.SendMessageAsync($"{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); .ConfigureAwait(false);
} }