Prevent users from giving others negative cookies

This commit is contained in:
Daan Boerlage 2022-07-25 15:41:44 +02:00
parent 2946ed523e
commit a3e10b15c1
Signed by: daan
GPG key ID: FCE070E1E4956606
4 changed files with 108 additions and 123 deletions

View file

@ -80,6 +80,12 @@ namespace Geekbot.Bot.Commands.Rpg
{ {
var giver = await GetUser(Context.User.Id); var giver = await GetUser(Context.User.Id);
if (amount < 1)
{
await ReplyAsync(Localization.Cookies.CantTakeCookies);
return;
}
if (giver.Cookies < amount) if (giver.Cookies < amount)
{ {
await ReplyAsync(Localization.Cookies.NotEnoughToGive); await ReplyAsync(Localization.Cookies.NotEnoughToGive);

View file

@ -1,123 +1,96 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000 //
// // Changes to this file may cause incorrect behavior and will be lost if
// Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated.
// the code is regenerated. // </auto-generated>
// </auto-generated> //------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace Geekbot.Core.Localization {
namespace Geekbot.Core.Localization { using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
// This class was auto-generated by the StronglyTypedResourceBuilder [System.Diagnostics.DebuggerNonUserCodeAttribute()]
// class via a tool like ResGen or Visual Studio. [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
// To add or remove a member, edit your .ResX file then rerun ResGen public class Cookies {
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] private static System.Resources.ResourceManager resourceMan;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] private static System.Globalization.CultureInfo resourceCulture;
public class Cookies {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
private static global::System.Resources.ResourceManager resourceMan; public Cookies() {
}
private static global::System.Globalization.CultureInfo resourceCulture;
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] public static System.Resources.ResourceManager ResourceManager {
public Cookies() { get {
} if (object.Equals(null, resourceMan)) {
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Geekbot.Core.Localization.Cookies", typeof(Cookies).Assembly);
/// <summary> resourceMan = temp;
/// Returns the cached ResourceManager instance used by this class. }
/// </summary> return resourceMan;
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] }
public static global::System.Resources.ResourceManager ResourceManager { }
get {
if (object.ReferenceEquals(resourceMan, null)) { [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Geekbot.Core.Localization.Cookies", typeof(Cookies).Assembly); public static System.Globalization.CultureInfo Culture {
resourceMan = temp; get {
} return resourceCulture;
return resourceMan; }
} set {
} resourceCulture = value;
}
/// <summary> }
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class. public static string GetCookies {
/// </summary> get {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] return ResourceManager.GetString("GetCookies", resourceCulture);
public static global::System.Globalization.CultureInfo Culture { }
get { }
return resourceCulture;
} public static string WaitForMoreCookies {
set { get {
resourceCulture = value; return ResourceManager.GetString("WaitForMoreCookies", resourceCulture);
} }
} }
/// <summary> public static string InYourJar {
/// Looks up a localized string similar to You ate {0} cookies, you&apos;ve only got {1} cookies left. get {
/// </summary> return ResourceManager.GetString("InYourJar", resourceCulture);
public static string AteCookies { }
get { }
return ResourceManager.GetString("AteCookies", resourceCulture);
} public static string Given {
} get {
return ResourceManager.GetString("Given", resourceCulture);
/// <summary> }
/// Looks up a localized string similar to You got {0} cookies, there are now {1} cookies in you cookie jar. }
/// </summary>
public static string GetCookies { public static string NotEnoughToGive {
get { get {
return ResourceManager.GetString("GetCookies", resourceCulture); return ResourceManager.GetString("NotEnoughToGive", resourceCulture);
} }
} }
/// <summary> public static string NotEnoughCookiesToEat {
/// Looks up a localized string similar to You gave {0} cookies to {1}. get {
/// </summary> return ResourceManager.GetString("NotEnoughCookiesToEat", resourceCulture);
public static string Given { }
get { }
return ResourceManager.GetString("Given", resourceCulture);
} public static string AteCookies {
} get {
return ResourceManager.GetString("AteCookies", resourceCulture);
/// <summary> }
/// Looks up a localized string similar to There are {0} cookies in you cookie jar. }
/// </summary>
public static string InYourJar { public static string CantTakeCookies {
get { get {
return ResourceManager.GetString("InYourJar", resourceCulture); return ResourceManager.GetString("CantTakeCookies", resourceCulture);
} }
} }
}
/// <summary> }
/// Looks up a localized string similar to Your cookie jar looks almost empty, you should probably not eat a cookie.
/// </summary>
public static string NotEnoughCookiesToEat {
get {
return ResourceManager.GetString("NotEnoughCookiesToEat", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You don&apos;t have enough cookies.
/// </summary>
public static string NotEnoughToGive {
get {
return ResourceManager.GetString("NotEnoughToGive", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You already got cookies today, you can have more cookies in {0}.
/// </summary>
public static string WaitForMoreCookies {
get {
return ResourceManager.GetString("WaitForMoreCookies", resourceCulture);
}
}
}
}

View file

@ -32,4 +32,7 @@
<data name="AteCookies" xml:space="preserve"> <data name="AteCookies" xml:space="preserve">
<value>Du hesch {0} guetzli gesse und hesch jezt no {1} übrig</value> <value>Du hesch {0} guetzli gesse und hesch jezt no {1} übrig</value>
</data> </data>
<data name="CantTakeCookies" xml:space="preserve">
<value>:police_officer: Du chasch nid guetzli vo anderne chlaue... </value>
</data>
</root> </root>

View file

@ -39,4 +39,7 @@
<data name="AteCookies" xml:space="preserve"> <data name="AteCookies" xml:space="preserve">
<value>You ate {0} cookies, you've only got {1} cookies left</value> <value>You ate {0} cookies, you've only got {1} cookies left</value>
</data> </data>
<data name="CantTakeCookies" xml:space="preserve">
<value>You can't take someone else's cookies</value>
</data>
</root> </root>