Animal racing done, more mass replacements
This commit is contained in:
parent
43c9e7d04d
commit
acebc6e914
@ -23,7 +23,7 @@ namespace NadekoBot.Classes
|
||||
|
||||
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.`")
|
||||
@ -46,7 +46,7 @@ namespace NadekoBot.Classes
|
||||
if (silent)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ namespace NadekoBot.Modules.Administration
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// await channel.SendMessage(msg);
|
||||
// await channel.SendMessageAsync(msg);
|
||||
// }
|
||||
// else if (ids[1].ToUpperInvariant().StartsWith("U:"))
|
||||
// {
|
||||
@ -553,7 +553,7 @@ namespace NadekoBot.Modules.Administration
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// await user.SendMessage(msg);
|
||||
// await user.SendMessageAsync(msg);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
@ -26,7 +26,7 @@
|
||||
// continue;
|
||||
// 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))
|
||||
// {
|
||||
// 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);
|
||||
// }
|
||||
// });
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
// 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; }));
|
||||
|
||||
// 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")
|
||||
|
@ -45,7 +45,7 @@
|
||||
// if (usr?.Status != UserStatus.Offline)
|
||||
// return;
|
||||
// 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 " +
|
||||
// $"`{e.Server.Name}` server while you were offline.\n" +
|
||||
// $"`Message:` {e.Message.Text}").ConfigureAwait(false);
|
||||
@ -76,7 +76,7 @@
|
||||
// //send merged messages to each channel
|
||||
// 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);
|
||||
@ -96,10 +96,10 @@
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// return;
|
||||
// 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);
|
||||
// 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}
|
||||
// `New:` {e.After.Topic}").ConfigureAwait(false);
|
||||
// }
|
||||
@ -117,7 +117,7 @@
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// 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 { }
|
||||
// }
|
||||
@ -133,7 +133,7 @@
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// 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 { }
|
||||
// }
|
||||
@ -148,7 +148,7 @@
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// 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 { }
|
||||
// }
|
||||
@ -163,7 +163,7 @@
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// 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 { }
|
||||
// }
|
||||
@ -178,7 +178,7 @@
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// 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 { }
|
||||
// }
|
||||
@ -193,7 +193,7 @@
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// 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 { }
|
||||
// }
|
||||
@ -213,13 +213,13 @@
|
||||
// return;
|
||||
// if (!string.IsNullOrWhiteSpace(e.Message.Text))
|
||||
// {
|
||||
// await ch.SendMessage(
|
||||
// await ch.SendMessageAsync(
|
||||
// $@"🕔`{prettyCurrentTime}` **New Message** `#{e.Channel.Name}`
|
||||
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// await ch.SendMessage(
|
||||
// await ch.SendMessageAsync(
|
||||
// $@"🕔`{prettyCurrentTime}` **File Uploaded** `#{e.Channel.Name}`
|
||||
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
|
||||
// }
|
||||
@ -242,13 +242,13 @@
|
||||
// return;
|
||||
// if (!string.IsNullOrWhiteSpace(e.Message.Text))
|
||||
// {
|
||||
// await ch.SendMessage(
|
||||
// await ch.SendMessageAsync(
|
||||
// $@"🕔`{prettyCurrentTime}` **Message** 🚮 `#{e.Channel.Name}`
|
||||
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Text.Unmention()}").ConfigureAwait(false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// await ch.SendMessage(
|
||||
// await ch.SendMessageAsync(
|
||||
// $@"🕔`{prettyCurrentTime}` **File Deleted** `#{e.Channel.Name}`
|
||||
//👤`{imsg.Author?.ToString() ?? ("NULL")}` {e.Message.Attachments.FirstOrDefault()?.ProxyUrl}").ConfigureAwait(false);
|
||||
// }
|
||||
@ -268,7 +268,7 @@
|
||||
// Channel ch;
|
||||
// if ((ch = e.Server.TextChannels.Where(tc => tc.Id == chId).FirstOrDefault()) == null)
|
||||
// return;
|
||||
// await ch.SendMessage(
|
||||
// await ch.SendMessageAsync(
|
||||
// $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}`
|
||||
//👤`{imsg.Author?.ToString() ?? ("NULL")}`
|
||||
// `Old:` {e.Before.Text.Unmention()}
|
||||
@ -318,15 +318,15 @@
|
||||
// }
|
||||
// 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)
|
||||
// {
|
||||
// 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)
|
||||
// {
|
||||
// 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
|
||||
// return;
|
||||
// await ch.SendMessage(str).ConfigureAwait(false);
|
||||
// await ch.SendMessageAsync(str).ConfigureAwait(false);
|
||||
// }
|
||||
// catch { }
|
||||
// }
|
||||
|
@ -47,7 +47,7 @@
|
||||
// catch { }
|
||||
// try
|
||||
// {
|
||||
// lastMessage = await ch.SendMessage(msg).ConfigureAwait(false);
|
||||
// lastMessage = await ch.SendMessageAsync(msg).ConfigureAwait(false);
|
||||
// }
|
||||
// catch { }
|
||||
// }
|
||||
|
@ -48,7 +48,7 @@
|
||||
// Greeted++;
|
||||
// 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 { }
|
||||
@ -57,7 +57,7 @@
|
||||
// {
|
||||
// if (channel == null) return;
|
||||
// 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)
|
||||
// {
|
||||
// await Task.Delay(30000).ConfigureAwait(false); // 5 minutes
|
||||
@ -84,13 +84,13 @@
|
||||
// if (controls.GreetPM)
|
||||
// {
|
||||
// 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
|
||||
// {
|
||||
// if (channel == null) return;
|
||||
// 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)
|
||||
// {
|
||||
// await Task.Delay(30000).ConfigureAwait(false); // 5 minutes
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
// try
|
||||
// {
|
||||
// await e.Server.Owner.SendMessage(
|
||||
// await e.Server.Owner.SendMessageAsync(
|
||||
// "I don't have manage server and/or Manage Channels permission," +
|
||||
// $" so I cannot run voice+text on **{e.Server.Name}** server.").ConfigureAwait(false);
|
||||
// }
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using System;
|
||||
@ -11,60 +12,53 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules.Gambling.Commands
|
||||
{
|
||||
public partial class Gambling
|
||||
{
|
||||
[Group]
|
||||
class AnimalRacing
|
||||
public class AnimalRacing
|
||||
{
|
||||
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)
|
||||
{
|
||||
return;
|
||||
await channel.SendMessageAsync("🏁 `Failed starting a race. Another race is probably running.`");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cgb.CreateCommand(Prefix + "joinrace")
|
||||
.Alias(Prefix + "jr")
|
||||
.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 =>
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task JoinRace(IMessage imsg, int amount = 0)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
|
||||
int amount;
|
||||
if (!int.TryParse(e.GetArg("amount"), out amount) || amount < 0)
|
||||
if (amount < 0)
|
||||
amount = 0;
|
||||
|
||||
var userFlowers = Gambling.GetUserFlowers(imsg.Author.Id);
|
||||
//todo DB
|
||||
//var userFlowers = Gambling.GetUserFlowers(imsg.Author.Id);
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
//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);
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (amount > 0)
|
||||
await FlowersHandler.RemoveFlowers(imsg.Author, "BetRace", (int)amount, true).ConfigureAwait(false);
|
||||
//if (amount > 0)
|
||||
// await FlowersHandler.RemoveFlowers(imsg.Author, "BetRace", (int)amount, true).ConfigureAwait(false);
|
||||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
await ar.JoinRace(imsg.Author, amount);
|
||||
|
||||
});
|
||||
await ar.JoinRace(imsg.Author as IGuildUser, amount);
|
||||
}
|
||||
|
||||
public class AnimalRace
|
||||
@ -78,10 +72,10 @@ namespace NadekoBot.Modules.Gambling.Commands
|
||||
private ulong serverId;
|
||||
private int messagesSinceGameStarted = 0;
|
||||
|
||||
public IGuildChannel raceChannel { get; set; }
|
||||
public ITextChannel raceChannel { get; set; }
|
||||
public bool Started { get; private set; } = false;
|
||||
|
||||
public AnimalRace(ulong serverId, Channel ch)
|
||||
public AnimalRace(ulong serverId, ITextChannel ch)
|
||||
{
|
||||
this.serverId = serverId;
|
||||
this.raceChannel = ch;
|
||||
@ -97,24 +91,26 @@ namespace NadekoBot.Modules.Gambling.Commands
|
||||
{
|
||||
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);
|
||||
Started = true;
|
||||
cancelSource.Cancel();
|
||||
if (t == fullgame)
|
||||
{
|
||||
await raceChannel.SendMessage("🏁`Race full, starting right now!`");
|
||||
await raceChannel.SendMessageAsync("🏁`Race full, starting right now!`");
|
||||
}
|
||||
else if (participants.Count > 1)
|
||||
{
|
||||
await raceChannel.SendMessage("🏁`Game starting with " + participants.Count + " participants.`");
|
||||
await raceChannel.SendMessageAsync("🏁`Game starting with " + participants.Count + " participants.`");
|
||||
}
|
||||
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();
|
||||
if (p != null)
|
||||
await FlowersHandler.AddFlowersAsync(p.User, "BetRace", p.AmountBet, true).ConfigureAwait(false);
|
||||
//todo DB
|
||||
//if (p != null)
|
||||
// await FlowersHandler.AddFlowersAsync(p.User, "BetRace", p.AmountBet, true).ConfigureAwait(false);
|
||||
End();
|
||||
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)
|
||||
try { await msg.Delete(); } catch { }
|
||||
msg = await raceChannel.SendMessage(text);
|
||||
try { await msg.DeleteAsync(); } catch { }
|
||||
msg = await raceChannel.SendMessageAsync(text).ConfigureAwait(false);
|
||||
messagesSinceGameStarted = 0;
|
||||
}
|
||||
else
|
||||
await msg.Edit(text);
|
||||
await msg.ModifyAsync(m => m.Content = text).ConfigureAwait(false);
|
||||
|
||||
await Task.Delay(2500);
|
||||
}
|
||||
@ -187,19 +183,20 @@ namespace NadekoBot.Modules.Gambling.Commands
|
||||
if (winner.AmountBet > 0)
|
||||
{
|
||||
var wonAmount = winner.AmountBet * (participants.Count - 1);
|
||||
await FlowersHandler.AddFlowersAsync(winner.User, "Won a Race", wonAmount).ConfigureAwait(false);
|
||||
await raceChannel.SendMessage($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race and {wonAmount}{NadekoBot.Config.CurrencySign}!**");
|
||||
//todo DB
|
||||
//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
|
||||
{
|
||||
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;
|
||||
messagesSinceGameStarted++;
|
||||
}
|
||||
@ -217,22 +214,22 @@ namespace NadekoBot.Modules.Gambling.Commands
|
||||
var 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;
|
||||
}
|
||||
var p = new Participant(u, animal, amount);
|
||||
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;
|
||||
}
|
||||
if (Started)
|
||||
{
|
||||
await raceChannel.SendMessage($"{u.Mention} `Race is already started`");
|
||||
await raceChannel.SendMessageAsync($"{u.Mention} `Race is already started`");
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -293,4 +290,5 @@ namespace NadekoBot.Modules.Gambling.Commands
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -69,10 +69,10 @@
|
||||
// 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.").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 msg.Edit("Starting new typing contest in **2**...").ConfigureAwait(false);
|
||||
// await Task.Delay(1000).ConfigureAwait(false);
|
||||
|
@ -63,7 +63,7 @@
|
||||
// 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).ConfigureAwait(false);
|
||||
// await channel.SendMessageAsync(msg).ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
// FirstPass = false;
|
||||
|
@ -61,7 +61,7 @@
|
||||
// if (ch == null)
|
||||
// return;
|
||||
|
||||
// await ch.SendMessage(
|
||||
// await ch.SendMessageAsync(
|
||||
// replacements.Aggregate(NadekoBot.Config.RemindMessageFormat,
|
||||
// (cur, replace) => cur.Replace(replace.Key, replace.Value(r)))
|
||||
// ).ConfigureAwait(false); //it works trust me
|
||||
|
@ -633,7 +633,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.").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;
|
||||
}
|
||||
var name = e.GetArg("name")?.Trim().ToLowerInvariant();
|
||||
@ -812,7 +812,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.").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));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
|
||||
@ -836,7 +836,7 @@ namespace NadekoBot.Modules.Music
|
||||
await lastFinishedMessage.Delete().ConfigureAwait(false);
|
||||
if (playingMessage != null)
|
||||
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")
|
||||
{
|
||||
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)}%`";
|
||||
playingMessage = await textCh.SendMessage(msgTxt).ConfigureAwait(false);
|
||||
playingMessage = await textCh.SendMessageAsync(msgTxt).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@ -877,12 +877,12 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
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;
|
||||
}
|
||||
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
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Permissions.Commands
|
||||
$"INVITE LINK in [{args.Channel.Name}/{args.Channel.Id}] channel.\n" +
|
||||
$"`Full message:` {args.Message.Text}");
|
||||
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.")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Permissions.Commands
|
||||
$"BANNED WORD in [{args.Channel.Name}/{args.Channel.Id}] channel.\n" +
|
||||
$"`Full message:` {args.Message.Text}");
|
||||
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.")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user