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);
if (amount < 1)
{
await ReplyAsync(Localization.Cookies.CantTakeCookies);
return;
}
if (giver.Cookies < amount)
{
await ReplyAsync(Localization.Cookies.NotEnoughToGive);

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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
// the code is regenerated.
@ -9,46 +8,35 @@
//------------------------------------------------------------------------------
namespace Geekbot.Core.Localization {
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// 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()]
using System;
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Geekbot.Core.Localization.Cookies", typeof(Cookies).Assembly);
if (object.Equals(null, resourceMan)) {
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Geekbot.Core.Localization.Cookies", typeof(Cookies).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// 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 {
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Globalization.CultureInfo Culture {
get {
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 {
get {
return ResourceManager.GetString("GetCookies", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You gave {0} cookies to {1}.
/// </summary>
public static string Given {
public static string WaitForMoreCookies {
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 {
get {
return ResourceManager.GetString("InYourJar", 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 {
public static string Given {
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 {
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 {
public static string NotEnoughCookiesToEat {
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">
<value>Du hesch {0} guetzli gesse und hesch jezt no {1} übrig</value>
</data>
<data name="CantTakeCookies" xml:space="preserve">
<value>:police_officer: Du chasch nid guetzli vo anderne chlaue... </value>
</data>
</root>

View file

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