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,7 +1,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <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.
@ -9,46 +8,35 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Geekbot.Core.Localization { namespace Geekbot.Core.Localization {
/// <summary> using System;
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
// class via a tool like ResGen or Visual Studio. [System.Diagnostics.DebuggerNonUserCodeAttribute()]
// To add or remove a member, edit your .ResX file then rerun ResGen [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Cookies { public class Cookies {
private static global::System.Resources.ResourceManager resourceMan; private static System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public Cookies() { public Cookies() {
} }
/// <summary> [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
/// Returns the cached ResourceManager instance used by this class. public static System.Resources.ResourceManager ResourceManager {
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.Equals(null, resourceMan)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Geekbot.Core.Localization.Cookies", typeof(Cookies).Assembly); System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Geekbot.Core.Localization.Cookies", typeof(Cookies).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
} }
} }
/// <summary> [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
/// Overrides the current thread's CurrentUICulture property for all public static System.Globalization.CultureInfo Culture {
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
@ -57,66 +45,51 @@ namespace Geekbot.Core.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to You ate {0} cookies, you&apos;ve only got {1} cookies left.
/// </summary>
public static string AteCookies {
get {
return ResourceManager.GetString("AteCookies", 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 GetCookies {
get { get {
return ResourceManager.GetString("GetCookies", resourceCulture); return ResourceManager.GetString("GetCookies", resourceCulture);
} }
} }
/// <summary> public static string WaitForMoreCookies {
/// Looks up a localized string similar to You gave {0} cookies to {1}.
/// </summary>
public static string Given {
get { get {
return ResourceManager.GetString("Given", resourceCulture); return ResourceManager.GetString("WaitForMoreCookies", 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 InYourJar {
get { get {
return ResourceManager.GetString("InYourJar", resourceCulture); return ResourceManager.GetString("InYourJar", resourceCulture);
} }
} }
/// <summary> public static string Given {
/// 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 { get {
return ResourceManager.GetString("NotEnoughCookiesToEat", resourceCulture); return ResourceManager.GetString("Given", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to You don&apos;t have enough cookies.
/// </summary>
public static string NotEnoughToGive { public static string NotEnoughToGive {
get { get {
return ResourceManager.GetString("NotEnoughToGive", resourceCulture); return ResourceManager.GetString("NotEnoughToGive", resourceCulture);
} }
} }
/// <summary> public static string NotEnoughCookiesToEat {
/// 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 { get {
return ResourceManager.GetString("WaitForMoreCookies", resourceCulture); return ResourceManager.GetString("NotEnoughCookiesToEat", resourceCulture);
}
}
public static string AteCookies {
get {
return ResourceManager.GetString("AteCookies", resourceCulture);
}
}
public static string CantTakeCookies {
get {
return ResourceManager.GetString("CantTakeCookies", 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>