added >plant and >pick commands, closes #163 , changed .net target to 4.6
This commit is contained in:
parent
2a71b43268
commit
778cc3b6b5
@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
|
||||||
</startup>
|
</startup>
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
|
||||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
|
@ -34,6 +34,14 @@ namespace NadekoBot.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal T FindOne<T>(Expression<Func<T, bool>> p) where T : IDataModel, new()
|
||||||
|
{
|
||||||
|
using (var conn = new SQLiteConnection(FilePath))
|
||||||
|
{
|
||||||
|
return conn.Table<T>().Where(p).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void DeleteAll<T>() where T : IDataModel
|
internal void DeleteAll<T>() where T : IDataModel
|
||||||
{
|
{
|
||||||
using (var conn = new SQLiteConnection(FilePath))
|
using (var conn = new SQLiteConnection(FilePath))
|
||||||
|
@ -4,7 +4,7 @@ namespace NadekoBot.Classes
|
|||||||
{
|
{
|
||||||
internal static class FlowersHandler
|
internal static class FlowersHandler
|
||||||
{
|
{
|
||||||
public static async Task AddFlowersAsync(Discord.User u, string reason, int amount)
|
public static async Task AddFlowersAsync(Discord.User u, string reason, int amount, bool silent = false)
|
||||||
{
|
{
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return;
|
return;
|
||||||
@ -17,6 +17,10 @@ namespace NadekoBot.Classes
|
|||||||
Value = amount,
|
Value = amount,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (silent)
|
||||||
|
return;
|
||||||
|
|
||||||
var flows = "";
|
var flows = "";
|
||||||
for (var i = 0; i < amount; i++)
|
for (var i = 0; i < amount; i++)
|
||||||
{
|
{
|
||||||
@ -25,19 +29,23 @@ namespace NadekoBot.Classes
|
|||||||
await u.SendMessage("👑Congratulations!👑\nYou received: " + flows);
|
await u.SendMessage("👑Congratulations!👑\nYou received: " + flows);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task RemoveFlowersAsync(Discord.User u, string reason, int amount)
|
public static bool RemoveFlowers(Discord.User u, string reason, int amount)
|
||||||
{
|
{
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return;
|
return false;
|
||||||
await Task.Run(() =>
|
var uid = (long)u.Id;
|
||||||
|
var state = DbHandler.Instance.FindOne<_DataModels.CurrencyState>(cs => cs.UserId == uid);
|
||||||
|
|
||||||
|
if (state.Value < amount)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DbHandler.Instance.InsertData(new _DataModels.CurrencyTransaction
|
||||||
{
|
{
|
||||||
DbHandler.Instance.InsertData(new _DataModels.CurrencyTransaction
|
Reason = reason,
|
||||||
{
|
UserId = (long)u.Id,
|
||||||
Reason = reason,
|
Value = -amount,
|
||||||
UserId = (long)u.Id,
|
|
||||||
Value = -amount,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
85
NadekoBot/Commands/PlantPick.cs
Normal file
85
NadekoBot/Commands/PlantPick.cs
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
using Discord;
|
||||||
|
using Discord.Commands;
|
||||||
|
using NadekoBot.Classes;
|
||||||
|
using NadekoBot.Modules;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NadekoBot.Commands
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Flower picking/planting idea is given to me by its
|
||||||
|
/// inceptor Violent Crumble from Game Developers League discord server
|
||||||
|
/// (he has !cookie and !nom) Thanks a lot Violent!
|
||||||
|
/// Check out GDL (its a growing gamedev community):
|
||||||
|
/// https://discord.gg/0TYNJfCU4De7YIk8
|
||||||
|
/// </summary>
|
||||||
|
class PlantPick : DiscordCommand
|
||||||
|
{
|
||||||
|
public PlantPick(DiscordModule module) : base(module)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//channelid/messageid pair
|
||||||
|
ConcurrentDictionary<ulong, Message> plantedFlowerChannels = new ConcurrentDictionary<ulong, Message>();
|
||||||
|
|
||||||
|
private object locker = new object();
|
||||||
|
|
||||||
|
internal override void Init(CommandGroupBuilder cgb)
|
||||||
|
{
|
||||||
|
cgb.CreateCommand(Module.Prefix + "pick")
|
||||||
|
.Description("Picks a flower planted in this channel.")
|
||||||
|
.Do(async e =>
|
||||||
|
{
|
||||||
|
Message msg;
|
||||||
|
|
||||||
|
await e.Message.Delete();
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(Module.Prefix + "plant")
|
||||||
|
.Description("Spend a flower to plant it in this channel. (If bot is restarted or crashes, flower will be lost)")
|
||||||
|
.Do(async e =>
|
||||||
|
{
|
||||||
|
lock (locker)
|
||||||
|
{
|
||||||
|
if (plantedFlowerChannels.ContainsKey(e.Channel.Id))
|
||||||
|
{
|
||||||
|
e.Channel.SendMessage($"There is already a {NadekoBot.Config.CurrencyName} in this channel.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var removed = FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1);
|
||||||
|
if (!removed)
|
||||||
|
{
|
||||||
|
e.Channel.SendMessage($"You don't have any {NadekoBot.Config.CurrencyName}s.").Wait();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rng = new Random();
|
||||||
|
var file = Directory.GetFiles("data/currency_images").OrderBy(s => rng.Next()).FirstOrDefault();
|
||||||
|
Message msg;
|
||||||
|
if (file == null)
|
||||||
|
msg = e.Channel.SendMessage("🌸").Result;
|
||||||
|
else
|
||||||
|
msg = e.Channel.SendFile(file).Result;
|
||||||
|
plantedFlowerChannels.TryAdd(e.Channel.Id, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
var msg2 = await e.Channel.SendMessage($"Oh how Nice! **{e.User.Name}** planted a flower. Pick it using {Module.Prefix}pick");
|
||||||
|
await Task.Delay(20000);
|
||||||
|
await msg2.Delete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -228,6 +228,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await e.Server.Ban(usr);
|
await e.Server.Ban(usr);
|
||||||
|
|
||||||
await e.Channel.SendMessage("Banned user " + usr.Name + " Id: " + usr.Id);
|
await e.Channel.SendMessage("Banned user " + usr.Name + " Id: " + usr.Id);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
using System;
|
using Discord.Commands;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord.Commands;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using Discord.Modules;
|
using Discord.Modules;
|
||||||
using NadekoBot.Classes.ClashOfClans;
|
using NadekoBot.Classes.ClashOfClans;
|
||||||
using NadekoBot.Modules;
|
using NadekoBot.Modules;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace NadekoBot.Commands {
|
namespace NadekoBot.Commands
|
||||||
|
{
|
||||||
internal class ClashOfClans : DiscordModule
|
internal class ClashOfClans : DiscordModule
|
||||||
{
|
{
|
||||||
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.ClashOfClans;
|
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.ClashOfClans;
|
||||||
@ -19,8 +17,10 @@ namespace NadekoBot.Commands {
|
|||||||
|
|
||||||
private readonly object writeLock = new object();
|
private readonly object writeLock = new object();
|
||||||
|
|
||||||
public override void Install(ModuleManager manager) {
|
public override void Install(ModuleManager manager)
|
||||||
manager.CreateCommands("", cgb => {
|
{
|
||||||
|
manager.CreateCommands("", cgb =>
|
||||||
|
{
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "createwar")
|
cgb.CreateCommand(Prefix + "createwar")
|
||||||
.Alias(Prefix + "cw")
|
.Alias(Prefix + "cw")
|
||||||
@ -28,38 +28,48 @@ namespace NadekoBot.Commands {
|
|||||||
$"Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name.\n**Usage**:{Prefix}cw 15 The Enemy Clan")
|
$"Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name.\n**Usage**:{Prefix}cw 15 The Enemy Clan")
|
||||||
.Parameter("size")
|
.Parameter("size")
|
||||||
.Parameter("enemy_clan", ParameterType.Unparsed)
|
.Parameter("enemy_clan", ParameterType.Unparsed)
|
||||||
.Do(async e => {
|
.Do(async e =>
|
||||||
|
{
|
||||||
if (!e.User.ServerPermissions.ManageChannels)
|
if (!e.User.ServerPermissions.ManageChannels)
|
||||||
return;
|
return;
|
||||||
List<ClashWar> wars;
|
List<ClashWar> wars;
|
||||||
if (!ClashWars.TryGetValue(e.Server.Id, out wars)) {
|
if (!ClashWars.TryGetValue(e.Server.Id, out wars))
|
||||||
|
{
|
||||||
wars = new List<ClashWar>();
|
wars = new List<ClashWar>();
|
||||||
if (!ClashWars.TryAdd(e.Server.Id, wars))
|
if (!ClashWars.TryAdd(e.Server.Id, wars))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var enemyClan = e.GetArg("enemy_clan");
|
var enemyClan = e.GetArg("enemy_clan");
|
||||||
if (string.IsNullOrWhiteSpace(enemyClan)) {
|
if (string.IsNullOrWhiteSpace(enemyClan))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int size;
|
int size;
|
||||||
if (!int.TryParse(e.GetArg("size"), out size) || size < 10 || size > 50 || size % 5 != 0) {
|
if (!int.TryParse(e.GetArg("size"), out size) || size < 10 || size > 50 || size % 5 != 0)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 Not a Valid war size");
|
await e.Channel.SendMessage("💢🔰 Not a Valid war size");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var cw = new ClashWar(enemyClan, size, e);
|
var cw = new ClashWar(enemyClan, size, e);
|
||||||
//cw.Start();
|
//cw.Start();
|
||||||
wars.Add(cw);
|
wars.Add(cw);
|
||||||
cw.OnUserTimeExpired += async (u) => {
|
cw.OnUserTimeExpired += async (u) =>
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
await
|
await
|
||||||
e.Channel.SendMessage(
|
e.Channel.SendMessage(
|
||||||
$"❗🔰**Claim from @{u} for a war against {cw.ShortPrint()} has expired.**");
|
$"❗🔰**Claim from @{u} for a war against {cw.ShortPrint()} has expired.**");
|
||||||
} catch { }
|
}
|
||||||
|
catch { }
|
||||||
};
|
};
|
||||||
cw.OnWarEnded += async () => {
|
cw.OnWarEnded += async () =>
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**");
|
await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**");
|
||||||
} catch { }
|
}
|
||||||
|
catch { }
|
||||||
};
|
};
|
||||||
await e.Channel.SendMessage($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**");
|
await e.Channel.SendMessage($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**");
|
||||||
//war with the index X started.
|
//war with the index X started.
|
||||||
@ -69,18 +79,23 @@ namespace NadekoBot.Commands {
|
|||||||
.Alias(Prefix + "startwar")
|
.Alias(Prefix + "startwar")
|
||||||
.Description("Starts a war with a given number.")
|
.Description("Starts a war with a given number.")
|
||||||
.Parameter("number", ParameterType.Required)
|
.Parameter("number", ParameterType.Required)
|
||||||
.Do(async e => {
|
.Do(async e =>
|
||||||
|
{
|
||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null) {
|
if (warsInfo == null)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var war = warsInfo.Item1[warsInfo.Item2];
|
var war = warsInfo.Item1[warsInfo.Item2];
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
var startTask = war.Start();
|
var startTask = war.Start();
|
||||||
await e.Channel.SendMessage($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**");
|
await e.Channel.SendMessage($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**");
|
||||||
await startTask;
|
await startTask;
|
||||||
} catch {
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
await e.Channel.SendMessage($"🔰**WAR AGAINST {war.ShortPrint()} IS ALREADY STARTED**");
|
await e.Channel.SendMessage($"🔰**WAR AGAINST {war.ShortPrint()} IS ALREADY STARTED**");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -89,13 +104,16 @@ namespace NadekoBot.Commands {
|
|||||||
.Alias(Prefix + "lw")
|
.Alias(Prefix + "lw")
|
||||||
.Description($"Shows the active war claims by a number. Shows all wars in a short way if no number is specified.\n**Usage**: {Prefix}lw [war_number] or {Prefix}lw")
|
.Description($"Shows the active war claims by a number. Shows all wars in a short way if no number is specified.\n**Usage**: {Prefix}lw [war_number] or {Prefix}lw")
|
||||||
.Parameter("number", ParameterType.Optional)
|
.Parameter("number", ParameterType.Optional)
|
||||||
.Do(async e => {
|
.Do(async e =>
|
||||||
|
{
|
||||||
// if number is null, print all wars in a short way
|
// if number is null, print all wars in a short way
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("number"))) {
|
if (string.IsNullOrWhiteSpace(e.GetArg("number")))
|
||||||
|
{
|
||||||
//check if there are any wars
|
//check if there are any wars
|
||||||
List<ClashWar> wars = null;
|
List<ClashWar> wars = null;
|
||||||
ClashWars.TryGetValue(e.Server.Id, out wars);
|
ClashWars.TryGetValue(e.Server.Id, out wars);
|
||||||
if (wars == null || wars.Count == 0) {
|
if (wars == null || wars.Count == 0)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("🔰 **No active wars.**");
|
await e.Channel.SendMessage("🔰 **No active wars.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,7 +121,8 @@ namespace NadekoBot.Commands {
|
|||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine("🔰 **LIST OF ACTIVE WARS**");
|
sb.AppendLine("🔰 **LIST OF ACTIVE WARS**");
|
||||||
sb.AppendLine("**-------------------------**");
|
sb.AppendLine("**-------------------------**");
|
||||||
for (var i = 0; i < wars.Count; i++) {
|
for (var i = 0; i < wars.Count; i++)
|
||||||
|
{
|
||||||
sb.AppendLine($"**#{i + 1}.** `Enemy:` **{wars[i].EnemyClan}**");
|
sb.AppendLine($"**#{i + 1}.** `Enemy:` **{wars[i].EnemyClan}**");
|
||||||
sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**");
|
sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**");
|
||||||
sb.AppendLine("**-------------------------**");
|
sb.AppendLine("**-------------------------**");
|
||||||
@ -113,7 +132,8 @@ namespace NadekoBot.Commands {
|
|||||||
}
|
}
|
||||||
//if number is not null, print the war needed
|
//if number is not null, print the war needed
|
||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null) {
|
if (warsInfo == null)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -127,14 +147,17 @@ namespace NadekoBot.Commands {
|
|||||||
.Parameter("number")
|
.Parameter("number")
|
||||||
.Parameter("baseNumber")
|
.Parameter("baseNumber")
|
||||||
.Parameter("other_name", ParameterType.Unparsed)
|
.Parameter("other_name", ParameterType.Unparsed)
|
||||||
.Do(async e => {
|
.Do(async e =>
|
||||||
|
{
|
||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null || warsInfo.Item1.Count == 0) {
|
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int baseNum;
|
int baseNum;
|
||||||
if (!int.TryParse(e.GetArg("baseNumber"), out baseNum)) {
|
if (!int.TryParse(e.GetArg("baseNumber"), out baseNum))
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **Invalid base number.**");
|
await e.Channel.SendMessage("💢🔰 **Invalid base number.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -142,11 +165,14 @@ namespace NadekoBot.Commands {
|
|||||||
string.IsNullOrWhiteSpace(e.GetArg("other_name")) ?
|
string.IsNullOrWhiteSpace(e.GetArg("other_name")) ?
|
||||||
e.User.Name :
|
e.User.Name :
|
||||||
e.GetArg("other_name");
|
e.GetArg("other_name");
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
var war = warsInfo.Item1[warsInfo.Item2];
|
var war = warsInfo.Item1[warsInfo.Item2];
|
||||||
war.Call(usr, baseNum - 1);
|
war.Call(usr, baseNum - 1);
|
||||||
await e.Channel.SendMessage($"🔰**{usr}** claimed a base #{baseNum} for a war against {war.ShortPrint()}");
|
await e.Channel.SendMessage($"🔰**{usr}** claimed a base #{baseNum} for a war against {war.ShortPrint()}");
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -156,9 +182,11 @@ namespace NadekoBot.Commands {
|
|||||||
.Description($"Finish your claim if you destroyed a base. Optional second argument finishes for someone else.\n**Usage**: {Prefix}cf [war_number] [optional_other_name]")
|
.Description($"Finish your claim if you destroyed a base. Optional second argument finishes for someone else.\n**Usage**: {Prefix}cf [war_number] [optional_other_name]")
|
||||||
.Parameter("number", ParameterType.Required)
|
.Parameter("number", ParameterType.Required)
|
||||||
.Parameter("other_name", ParameterType.Unparsed)
|
.Parameter("other_name", ParameterType.Unparsed)
|
||||||
.Do(async e => {
|
.Do(async e =>
|
||||||
|
{
|
||||||
var warInfo = GetInfo(e);
|
var warInfo = GetInfo(e);
|
||||||
if (warInfo == null || warInfo.Item1.Count == 0) {
|
if (warInfo == null || warInfo.Item1.Count == 0)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -168,10 +196,13 @@ namespace NadekoBot.Commands {
|
|||||||
e.GetArg("other_name");
|
e.GetArg("other_name");
|
||||||
|
|
||||||
var war = warInfo.Item1[warInfo.Item2];
|
var war = warInfo.Item1[warInfo.Item2];
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
var baseNum = war.FinishClaim(usr);
|
var baseNum = war.FinishClaim(usr);
|
||||||
await e.Channel.SendMessage($"❗🔰{e.User.Mention} **DESTROYED** a base #{baseNum + 1} in a war against {war.ShortPrint()}");
|
await e.Channel.SendMessage($"❗🔰{e.User.Mention} **DESTROYED** a base #{baseNum + 1} in a war against {war.ShortPrint()}");
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -182,9 +213,11 @@ namespace NadekoBot.Commands {
|
|||||||
.Description($"Removes your claim from a certain war. Optional second argument denotes a person in whos place to unclaim\n**Usage**: {Prefix}uc [war_number] [optional_other_name]")
|
.Description($"Removes your claim from a certain war. Optional second argument denotes a person in whos place to unclaim\n**Usage**: {Prefix}uc [war_number] [optional_other_name]")
|
||||||
.Parameter("number", ParameterType.Required)
|
.Parameter("number", ParameterType.Required)
|
||||||
.Parameter("other_name", ParameterType.Unparsed)
|
.Parameter("other_name", ParameterType.Unparsed)
|
||||||
.Do(async e => {
|
.Do(async e =>
|
||||||
|
{
|
||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null || warsInfo.Item1.Count == 0) {
|
if (warsInfo == null || warsInfo.Item1.Count == 0)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
await e.Channel.SendMessage("💢🔰 **That war does not exist.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -192,11 +225,14 @@ namespace NadekoBot.Commands {
|
|||||||
string.IsNullOrWhiteSpace(e.GetArg("other_name")) ?
|
string.IsNullOrWhiteSpace(e.GetArg("other_name")) ?
|
||||||
e.User.Name :
|
e.User.Name :
|
||||||
e.GetArg("other_name");
|
e.GetArg("other_name");
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
var war = warsInfo.Item1[warsInfo.Item2];
|
var war = warsInfo.Item1[warsInfo.Item2];
|
||||||
var baseNumber = war.Uncall(usr);
|
var baseNumber = war.Uncall(usr);
|
||||||
await e.Channel.SendMessage($"🔰 @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}");
|
await e.Channel.SendMessage($"🔰 @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}");
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
await e.Channel.SendMessage($"💢🔰 {ex.Message}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -205,9 +241,11 @@ namespace NadekoBot.Commands {
|
|||||||
.Alias(Prefix + "ew")
|
.Alias(Prefix + "ew")
|
||||||
.Description($"Ends the war with a given index.\n**Usage**:{Prefix}ew [war_number]")
|
.Description($"Ends the war with a given index.\n**Usage**:{Prefix}ew [war_number]")
|
||||||
.Parameter("number")
|
.Parameter("number")
|
||||||
.Do(async e => {
|
.Do(async e =>
|
||||||
|
{
|
||||||
var warsInfo = GetInfo(e);
|
var warsInfo = GetInfo(e);
|
||||||
if (warsInfo == null) {
|
if (warsInfo == null)
|
||||||
|
{
|
||||||
await e.Channel.SendMessage("💢🔰 That war does not exist.");
|
await e.Channel.SendMessage("💢🔰 That war does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -219,18 +257,21 @@ namespace NadekoBot.Commands {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Tuple<List<ClashWar>, int> GetInfo(CommandEventArgs e) {
|
private static Tuple<List<ClashWar>, int> GetInfo(CommandEventArgs e)
|
||||||
|
{
|
||||||
//check if there are any wars
|
//check if there are any wars
|
||||||
List<ClashWar> wars = null;
|
List<ClashWar> wars = null;
|
||||||
ClashWars.TryGetValue(e.Server.Id, out wars);
|
ClashWars.TryGetValue(e.Server.Id, out wars);
|
||||||
if (wars == null || wars.Count == 0) {
|
if (wars == null || wars.Count == 0)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// get the number of the war
|
// get the number of the war
|
||||||
int num;
|
int num;
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("number")))
|
if (string.IsNullOrWhiteSpace(e.GetArg("number")))
|
||||||
num = 0;
|
num = 0;
|
||||||
else if (!int.TryParse(e.GetArg("number"), out num) || num > wars.Count) {
|
else if (!int.TryParse(e.GetArg("number"), out num) || num > wars.Count)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
num -= 1;
|
num -= 1;
|
||||||
|
@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await FlowersHandler.RemoveFlowersAsync(e.User, "Gift", (int)amount);
|
FlowersHandler.RemoveFlowers(e.User, "Gift", (int)amount);
|
||||||
await FlowersHandler.AddFlowersAsync(mentionedUser, "Gift", (int)amount);
|
await FlowersHandler.AddFlowersAsync(mentionedUser, "Gift", (int)amount);
|
||||||
|
|
||||||
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}!");
|
||||||
@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
if (mentionedUser == null)
|
if (mentionedUser == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await FlowersHandler.RemoveFlowersAsync(mentionedUser, $"Taken by bot owner.({e.User.Name}/{e.User.Id})", (int)amount);
|
FlowersHandler.RemoveFlowers(mentionedUser, $"Taken by bot owner.({e.User.Name}/{e.User.Id})", (int)amount);
|
||||||
|
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from {mentionedUser.Mention}!");
|
await e.Channel.SendMessage($"{e.User.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from {mentionedUser.Mention}!");
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,7 @@ namespace NadekoBot.Modules
|
|||||||
commands.Add(new Trivia(this));
|
commands.Add(new Trivia(this));
|
||||||
commands.Add(new SpeedTyping(this));
|
commands.Add(new SpeedTyping(this));
|
||||||
commands.Add(new PollCommand(this));
|
commands.Add(new PollCommand(this));
|
||||||
|
commands.Add(new PlantPick(this));
|
||||||
//commands.Add(new BetrayGame(this));
|
//commands.Add(new BetrayGame(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name;
|
var target = (usr.Id == e.User.Id) ? "yourself" : usr.Name;
|
||||||
await FlowersHandler.RemoveFlowersAsync(e.User, $"Poke-Heal {target}", amount);
|
FlowersHandler.RemoveFlowers(e.User, $"Poke-Heal {target}", amount);
|
||||||
//healing
|
//healing
|
||||||
targetStats.Hp = targetStats.MaxHp;
|
targetStats.Hp = targetStats.MaxHp;
|
||||||
if (HP < 0)
|
if (HP < 0)
|
||||||
@ -285,13 +285,13 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
|
|
||||||
//Payment~
|
//Payment~
|
||||||
var amount = 1;
|
var amount = 1;
|
||||||
var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
var pts = DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
|
||||||
if (pts < amount)
|
if (pts < amount)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough NadekoFlowers! \nYou still need {amount - pts} to be able to do this!");
|
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough NadekoFlowers! \nYou still need {amount - pts} to be able to do this!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await FlowersHandler.RemoveFlowersAsync(e.User, $"set usertype to {targetTypeStr}", amount);
|
FlowersHandler.RemoveFlowers(e.User, $"set usertype to {targetTypeStr}", amount);
|
||||||
//Actually changing the type here
|
//Actually changing the type here
|
||||||
var preTypes = DbHandler.Instance.GetAllRows<UserPokeTypes>();
|
var preTypes = DbHandler.Instance.GetAllRows<UserPokeTypes>();
|
||||||
Dictionary<long, int> Dict = preTypes.ToDictionary(x => x.UserId, y => y.Id);
|
Dictionary<long, int> Dict = preTypes.ToDictionary(x => x.UserId, y => y.Id);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>NadekoBot</RootNamespace>
|
<RootNamespace>NadekoBot</RootNamespace>
|
||||||
<AssemblyName>NadekoBot</AssemblyName>
|
<AssemblyName>NadekoBot</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
@ -32,6 +32,7 @@
|
|||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
<NuGetPackageImportStamp>
|
<NuGetPackageImportStamp>
|
||||||
</NuGetPackageImportStamp>
|
</NuGetPackageImportStamp>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -151,6 +152,7 @@
|
|||||||
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
|
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\UserQuoteModel.cs" />
|
<Compile Include="Classes\_DataModels\UserQuoteModel.cs" />
|
||||||
<Compile Include="Commands\BetrayGame.cs" />
|
<Compile Include="Commands\BetrayGame.cs" />
|
||||||
|
<Compile Include="Commands\PlantPick.cs" />
|
||||||
<Compile Include="Modules\Administration\Commands\CrossServerTextChannel.cs" />
|
<Compile Include="Modules\Administration\Commands\CrossServerTextChannel.cs" />
|
||||||
<Compile Include="Modules\Administration\Commands\Remind.cs" />
|
<Compile Include="Modules\Administration\Commands\Remind.cs" />
|
||||||
<Compile Include="Modules\Administration\Commands\SelfAssignedRolesCommand.cs" />
|
<Compile Include="Modules\Administration\Commands\SelfAssignedRolesCommand.cs" />
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
|
||||||
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
|
||||||
<package id="Parse" version="1.6.2" targetFramework="net452" />
|
<package id="Parse" version="1.6.2" targetFramework="net452" />
|
||||||
<package id="RestSharp" version="105.2.3" targetFramework="net452" />
|
<package id="RestSharp" version="105.2.3" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="sqlite-net" version="1.0.8" targetFramework="net452" />
|
<package id="sqlite-net" version="1.0.8" targetFramework="net452" />
|
||||||
<package id="taglib" version="2.1.0.0" targetFramework="net452" />
|
<package id="taglib" version="2.1.0.0" targetFramework="net452" />
|
||||||
<package id="VideoLibrary" version="1.3.3" targetFramework="net452" />
|
<package id="VideoLibrary" version="1.3.3" targetFramework="net452" />
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>Tests</RootNamespace>
|
<RootNamespace>Tests</RootNamespace>
|
||||||
<AssemblyName>Tests</AssemblyName>
|
<AssemblyName>Tests</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
Loading…
Reference in New Issue
Block a user