.race will now repost when there's spam in the chat. close #1589
This commit is contained in:
parent
99a2c46038
commit
ae35adb48a
@ -41,27 +41,31 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
var ar = new AnimalRace(_cs, _bc.BotConfig.RaceAnimals.Shuffle().ToArray());
|
var ar = new AnimalRace(_cs, _bc.BotConfig.RaceAnimals.Shuffle().ToArray());
|
||||||
if (!AnimalRaces.TryAdd(Context.Guild.Id, ar))
|
if (!AnimalRaces.TryAdd(Context.Guild.Id, ar))
|
||||||
return Context.Channel.SendErrorAsync(GetText("animal_race"), GetText("animal_race_already_started"));
|
return Context.Channel.SendErrorAsync(GetText("animal_race"), GetText("animal_race_already_started"));
|
||||||
|
|
||||||
ar.Initialize();
|
ar.Initialize();
|
||||||
|
|
||||||
ar.OnStartingFailed += Ar_OnStartingFailed;
|
var count = 0;
|
||||||
ar.OnStateUpdate += Ar_OnStateUpdate;
|
Task _client_MessageReceived(SocketMessage arg)
|
||||||
ar.OnEnded += Ar_OnEnded;
|
{
|
||||||
ar.OnStarted += Ar_OnStarted;
|
var _ = Task.Run(() => {
|
||||||
|
try
|
||||||
return Context.Channel.SendConfirmAsync(GetText("animal_race"), GetText("animal_race_starting"),
|
{
|
||||||
footer: GetText("animal_race_join_instr", Prefix));
|
if (arg.Channel.Id == Context.Channel.Id)
|
||||||
|
{
|
||||||
|
if (ar.CurrentPhase == AnimalRace.Phase.Running && ++count % 9 == 0)
|
||||||
|
{
|
||||||
|
raceMessage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
});
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task Ar_OnStarted(AnimalRace race)
|
Task Ar_OnEnded(AnimalRace race)
|
||||||
{
|
|
||||||
if(race.Users.Length == race.MaxUsers)
|
|
||||||
return Context.Channel.SendConfirmAsync(GetText("animal_race"), GetText("animal_race_full"));
|
|
||||||
else
|
|
||||||
return Context.Channel.SendConfirmAsync(GetText("animal_race"), GetText("animal_race_starting_with_x", race.Users.Length));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task Ar_OnEnded(AnimalRace race)
|
|
||||||
{
|
{
|
||||||
|
_client.MessageReceived -= _client_MessageReceived;
|
||||||
AnimalRaces.TryRemove(Context.Guild.Id, out _);
|
AnimalRaces.TryRemove(Context.Guild.Id, out _);
|
||||||
var winner = race.FinishedUsers[0];
|
var winner = race.FinishedUsers[0];
|
||||||
if (race.FinishedUsers[0].Bet > 0)
|
if (race.FinishedUsers[0].Bet > 0)
|
||||||
@ -77,6 +81,24 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ar.OnStartingFailed += Ar_OnStartingFailed;
|
||||||
|
ar.OnStateUpdate += Ar_OnStateUpdate;
|
||||||
|
ar.OnEnded += Ar_OnEnded;
|
||||||
|
ar.OnStarted += Ar_OnStarted;
|
||||||
|
_client.MessageReceived += _client_MessageReceived;
|
||||||
|
|
||||||
|
return Context.Channel.SendConfirmAsync(GetText("animal_race"), GetText("animal_race_starting"),
|
||||||
|
footer: GetText("animal_race_join_instr", Prefix));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task Ar_OnStarted(AnimalRace race)
|
||||||
|
{
|
||||||
|
if(race.Users.Length == race.MaxUsers)
|
||||||
|
return Context.Channel.SendConfirmAsync(GetText("animal_race"), GetText("animal_race_full"));
|
||||||
|
else
|
||||||
|
return Context.Channel.SendConfirmAsync(GetText("animal_race"), GetText("animal_race_starting_with_x", race.Users.Length));
|
||||||
|
}
|
||||||
|
|
||||||
private async Task Ar_OnStateUpdate(AnimalRace race)
|
private async Task Ar_OnStateUpdate(AnimalRace race)
|
||||||
{
|
{
|
||||||
var text = $@"|🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🔚|
|
var text = $@"|🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🔚|
|
||||||
@ -88,11 +110,13 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}))}
|
}))}
|
||||||
|🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🔚|";
|
|🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🔚|";
|
||||||
|
|
||||||
if (raceMessage == null)
|
var msg = raceMessage;
|
||||||
|
|
||||||
|
if (msg == null)
|
||||||
raceMessage = await Context.Channel.SendConfirmAsync(text)
|
raceMessage = await Context.Channel.SendConfirmAsync(text)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await raceMessage.ModifyAsync(x => x.Embed = new EmbedBuilder()
|
await msg.ModifyAsync(x => x.Embed = new EmbedBuilder()
|
||||||
.WithTitle(GetText("animal_race"))
|
.WithTitle(GetText("animal_race"))
|
||||||
.WithDescription(text)
|
.WithDescription(text)
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
|
Loading…
Reference in New Issue
Block a user