mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	add: Added .honeypot command
fix: Fixed .betdraw not respecting max bet limit
This commit is contained in:
		
							
								
								
									
										11
									
								
								src/NadekoBot/Db/Models/HoneypotChannel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/NadekoBot/Db/Models/HoneypotChannel.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Db.Models;
 | 
			
		||||
 | 
			
		||||
public class HoneypotChannel
 | 
			
		||||
{
 | 
			
		||||
    [Key]
 | 
			
		||||
    public ulong GuildId { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    public ulong ChannelId { get; set; }
 | 
			
		||||
}
 | 
			
		||||
@@ -59,6 +59,7 @@ public abstract class NadekoContext : DbContext
 | 
			
		||||
 | 
			
		||||
    public DbSet<TodoModel> Todos { get; set; }
 | 
			
		||||
    public DbSet<ArchivedTodoListModel> TodosArchive { get; set; }
 | 
			
		||||
    public DbSet<HoneypotChannel> HoneyPotChannels { get; set; }
 | 
			
		||||
 | 
			
		||||
    // todo add guild colors
 | 
			
		||||
    // public DbSet<GuildColors> GuildColors { get; set; }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3803
									
								
								src/NadekoBot/Migrations/Mysql/20240627033532_honeypot.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										3803
									
								
								src/NadekoBot/Migrations/Mysql/20240627033532_honeypot.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										36
									
								
								src/NadekoBot/Migrations/Mysql/20240627033532_honeypot.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/NadekoBot/Migrations/Mysql/20240627033532_honeypot.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
using Microsoft.EntityFrameworkCore.Metadata;
 | 
			
		||||
using Microsoft.EntityFrameworkCore.Migrations;
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Migrations.Mysql
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public partial class honeypot : Migration
 | 
			
		||||
    {
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Up(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.CreateTable(
 | 
			
		||||
                name: "honeypotchannels",
 | 
			
		||||
                columns: table => new
 | 
			
		||||
                {
 | 
			
		||||
                    guildid = table.Column<ulong>(type: "bigint unsigned", nullable: false)
 | 
			
		||||
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
 | 
			
		||||
                    channelid = table.Column<ulong>(type: "bigint unsigned", nullable: false)
 | 
			
		||||
                },
 | 
			
		||||
                constraints: table =>
 | 
			
		||||
                {
 | 
			
		||||
                    table.PrimaryKey("pk_honeypotchannels", x => x.guildid);
 | 
			
		||||
                })
 | 
			
		||||
                .Annotation("MySql:CharSet", "utf8mb4");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Down(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.DropTable(
 | 
			
		||||
                name: "honeypotchannels");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1388,6 +1388,25 @@ namespace NadekoBot.Migrations.Mysql
 | 
			
		||||
                    b.ToTable("guildconfigs", (string)null);
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            modelBuilder.Entity("NadekoBot.Db.Models.HoneypotChannel", b =>
 | 
			
		||||
                {
 | 
			
		||||
                    b.Property<ulong>("GuildId")
 | 
			
		||||
                        .ValueGeneratedOnAdd()
 | 
			
		||||
                        .HasColumnType("bigint unsigned")
 | 
			
		||||
                        .HasColumnName("guildid");
 | 
			
		||||
 | 
			
		||||
                    MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("GuildId"));
 | 
			
		||||
 | 
			
		||||
                    b.Property<ulong>("ChannelId")
 | 
			
		||||
                        .HasColumnType("bigint unsigned")
 | 
			
		||||
                        .HasColumnName("channelid");
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("GuildId")
 | 
			
		||||
                        .HasName("pk_honeypotchannels");
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("honeypotchannels", (string)null);
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            modelBuilder.Entity("NadekoBot.Db.Models.IgnoredLogItem", b =>
 | 
			
		||||
                {
 | 
			
		||||
                    b.Property<int>("Id")
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3798
									
								
								src/NadekoBot/Migrations/PostgreSql/20240627033522_honeypot.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										3798
									
								
								src/NadekoBot/Migrations/PostgreSql/20240627033522_honeypot.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
using Microsoft.EntityFrameworkCore.Migrations;
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Migrations.PostgreSql
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public partial class honeypot : Migration
 | 
			
		||||
    {
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Up(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.CreateTable(
 | 
			
		||||
                name: "honeypotchannels",
 | 
			
		||||
                columns: table => new
 | 
			
		||||
                {
 | 
			
		||||
                    guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
 | 
			
		||||
                    channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false)
 | 
			
		||||
                },
 | 
			
		||||
                constraints: table =>
 | 
			
		||||
                {
 | 
			
		||||
                    table.PrimaryKey("pk_honeypotchannels", x => x.guildid);
 | 
			
		||||
                });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Down(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.DropTable(
 | 
			
		||||
                name: "honeypotchannels");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1387,6 +1387,23 @@ namespace NadekoBot.Migrations.PostgreSql
 | 
			
		||||
                    b.ToTable("guildconfigs", (string)null);
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            modelBuilder.Entity("NadekoBot.Db.Models.HoneypotChannel", b =>
 | 
			
		||||
                {
 | 
			
		||||
                    b.Property<decimal>("GuildId")
 | 
			
		||||
                        .ValueGeneratedOnAdd()
 | 
			
		||||
                        .HasColumnType("numeric(20,0)")
 | 
			
		||||
                        .HasColumnName("guildid");
 | 
			
		||||
 | 
			
		||||
                    b.Property<decimal>("ChannelId")
 | 
			
		||||
                        .HasColumnType("numeric(20,0)")
 | 
			
		||||
                        .HasColumnName("channelid");
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("GuildId")
 | 
			
		||||
                        .HasName("pk_honeypotchannels");
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("honeypotchannels", (string)null);
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            modelBuilder.Entity("NadekoBot.Db.Models.IgnoredLogItem", b =>
 | 
			
		||||
                {
 | 
			
		||||
                    b.Property<int>("Id")
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2935
									
								
								src/NadekoBot/Migrations/Sqlite/20240627033508_honeypot.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										2935
									
								
								src/NadekoBot/Migrations/Sqlite/20240627033508_honeypot.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										34
									
								
								src/NadekoBot/Migrations/Sqlite/20240627033508_honeypot.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/NadekoBot/Migrations/Sqlite/20240627033508_honeypot.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
using Microsoft.EntityFrameworkCore.Migrations;
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Migrations
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public partial class honeypot : Migration
 | 
			
		||||
    {
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Up(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.CreateTable(
 | 
			
		||||
                name: "HoneyPotChannels",
 | 
			
		||||
                columns: table => new
 | 
			
		||||
                {
 | 
			
		||||
                    GuildId = table.Column<ulong>(type: "INTEGER", nullable: false)
 | 
			
		||||
                        .Annotation("Sqlite:Autoincrement", true),
 | 
			
		||||
                    ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false)
 | 
			
		||||
                },
 | 
			
		||||
                constraints: table =>
 | 
			
		||||
                {
 | 
			
		||||
                    table.PrimaryKey("PK_HoneyPotChannels", x => x.GuildId);
 | 
			
		||||
                });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Down(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.DropTable(
 | 
			
		||||
                name: "HoneyPotChannels");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1033,6 +1033,20 @@ namespace NadekoBot.Migrations
 | 
			
		||||
                    b.ToTable("GuildConfigs");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            modelBuilder.Entity("NadekoBot.Db.Models.HoneypotChannel", b =>
 | 
			
		||||
                {
 | 
			
		||||
                    b.Property<ulong>("GuildId")
 | 
			
		||||
                        .ValueGeneratedOnAdd()
 | 
			
		||||
                        .HasColumnType("INTEGER");
 | 
			
		||||
 | 
			
		||||
                    b.Property<ulong>("ChannelId")
 | 
			
		||||
                        .HasColumnType("INTEGER");
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("GuildId");
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("HoneyPotChannels");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            modelBuilder.Entity("NadekoBot.Db.Models.IgnoredLogItem", b =>
 | 
			
		||||
                {
 | 
			
		||||
                    b.Property<int>("Id")
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,94 @@
 | 
			
		||||
using LinqToDB;
 | 
			
		||||
using LinqToDB.EntityFrameworkCore;
 | 
			
		||||
using NadekoBot.Common.ModuleBehaviors;
 | 
			
		||||
using NadekoBot.Db.Models;
 | 
			
		||||
using System.Threading.Channels;
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Modules.Administration.Honeypot;
 | 
			
		||||
 | 
			
		||||
public sealed class HoneyPotService : IHoneyPotService, IReadyExecutor, IExecNoCommand, INService
 | 
			
		||||
{
 | 
			
		||||
    private readonly DbService _db;
 | 
			
		||||
    private readonly CommandHandler _handler;
 | 
			
		||||
 | 
			
		||||
    private ConcurrentHashSet<ulong> _channels = new();
 | 
			
		||||
 | 
			
		||||
    private Channel<SocketGuildUser> _punishments = Channel.CreateBounded<SocketGuildUser>(
 | 
			
		||||
        new BoundedChannelOptions(100)
 | 
			
		||||
        {
 | 
			
		||||
            FullMode = BoundedChannelFullMode.DropOldest,
 | 
			
		||||
            SingleReader = true,
 | 
			
		||||
            SingleWriter = false,
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
    public HoneyPotService(DbService db, CommandHandler handler)
 | 
			
		||||
    {
 | 
			
		||||
        _db = db;
 | 
			
		||||
        _handler = handler;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> ToggleHoneypotChannel(ulong guildId, ulong channelId)
 | 
			
		||||
    {
 | 
			
		||||
        await using var uow = _db.GetDbContext();
 | 
			
		||||
 | 
			
		||||
        var deleted = await uow.HoneyPotChannels
 | 
			
		||||
                               .Where(x => x.GuildId == guildId)
 | 
			
		||||
                               .DeleteWithOutputAsync();
 | 
			
		||||
 | 
			
		||||
        if (deleted.Length > 0)
 | 
			
		||||
        {
 | 
			
		||||
            _channels.TryRemove(deleted[0].ChannelId);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await uow.HoneyPotChannels
 | 
			
		||||
                 .ToLinqToDBTable()
 | 
			
		||||
                 .InsertAsync(() => new HoneypotChannel
 | 
			
		||||
                 {
 | 
			
		||||
                     GuildId = guildId,
 | 
			
		||||
                     ChannelId = channelId
 | 
			
		||||
                 });
 | 
			
		||||
 | 
			
		||||
        _channels.Add(channelId);
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async Task OnReadyAsync()
 | 
			
		||||
    {
 | 
			
		||||
        await using var uow = _db.GetDbContext();
 | 
			
		||||
 | 
			
		||||
        var channels = await uow.HoneyPotChannels
 | 
			
		||||
                                .Select(x => x.ChannelId)
 | 
			
		||||
                                .ToListAsyncLinqToDB();
 | 
			
		||||
 | 
			
		||||
        _channels = new(channels);
 | 
			
		||||
 | 
			
		||||
        while (await _punishments.Reader.WaitToReadAsync())
 | 
			
		||||
        {
 | 
			
		||||
            while (_punishments.Reader.TryRead(out var user))
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    Log.Information("Honeypot caught user {User} [{UserId}]", user, user.Id);
 | 
			
		||||
                    await user.BanAsync();
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception e)
 | 
			
		||||
                {
 | 
			
		||||
                    Log.Warning(e, "Failed banning {User} due to {Error}", user, e.Message);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                await Task.Delay(1000);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg)
 | 
			
		||||
    {
 | 
			
		||||
        if (_channels.Contains(msg.Channel.Id) && msg.Author is SocketGuildUser sgu)
 | 
			
		||||
        {
 | 
			
		||||
            if (!sgu.GuildPermissions.BanMembers)
 | 
			
		||||
                await _punishments.Writer.WriteAsync(sgu);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,29 @@
 | 
			
		||||
using NadekoBot.Modules.Administration.Honeypot;
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Modules.Administration;
 | 
			
		||||
 | 
			
		||||
public partial class Administration
 | 
			
		||||
{
 | 
			
		||||
    [Group]
 | 
			
		||||
    public partial class HoneypotCommands : NadekoModule
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IHoneyPotService _service;
 | 
			
		||||
 | 
			
		||||
        public HoneypotCommands(IHoneyPotService service)
 | 
			
		||||
            => _service = service;
 | 
			
		||||
 | 
			
		||||
        [Cmd]
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        [RequireUserPermission(GuildPermission.Administrator)]
 | 
			
		||||
        [RequireBotPermission(GuildPermission.BanMembers)]
 | 
			
		||||
        public async Task Honeypot()
 | 
			
		||||
        {
 | 
			
		||||
            var enabled = await _service.ToggleHoneypotChannel(ctx.Guild.Id, ctx.Channel.Id);
 | 
			
		||||
 | 
			
		||||
            if (enabled)
 | 
			
		||||
                await Response().Confirm(strs.honeypot_on).SendAsync();
 | 
			
		||||
            else
 | 
			
		||||
                await Response().Confirm(strs.honeypot_off).SendAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,6 @@
 | 
			
		||||
namespace NadekoBot.Modules.Administration.Honeypot;
 | 
			
		||||
 | 
			
		||||
public interface IHoneyPotService
 | 
			
		||||
{
 | 
			
		||||
    public Task<bool> ToggleHoneypotChannel(ulong guildId, ulong channelId);
 | 
			
		||||
}
 | 
			
		||||
@@ -17,7 +17,8 @@ public partial class Gambling
 | 
			
		||||
        private static readonly ConcurrentDictionary<IGuild, Deck> _allDecks = new();
 | 
			
		||||
        private readonly IImageCache _images;
 | 
			
		||||
 | 
			
		||||
        public DrawCommands(IImageCache images, GamblingConfigService gcs) : base(gcs)
 | 
			
		||||
        public DrawCommands(IImageCache images, GamblingConfigService gcs)
 | 
			
		||||
            : base(gcs)
 | 
			
		||||
            => _images = images;
 | 
			
		||||
 | 
			
		||||
        private async Task InternalDraw(int count, ulong? guildId = null)
 | 
			
		||||
@@ -56,8 +57,8 @@ public partial class Gambling
 | 
			
		||||
                i.Dispose();
 | 
			
		||||
 | 
			
		||||
            var eb = _sender.CreateEmbed()
 | 
			
		||||
                .WithOkColor();
 | 
			
		||||
            
 | 
			
		||||
                            .WithOkColor();
 | 
			
		||||
 | 
			
		||||
            var toSend = string.Empty;
 | 
			
		||||
            if (cardObjects.Count == 5)
 | 
			
		||||
                eb.AddField(GetText(strs.hand_value), Deck.GetHandValue(cardObjects), true);
 | 
			
		||||
@@ -71,7 +72,7 @@ public partial class Gambling
 | 
			
		||||
 | 
			
		||||
            if (count > 1)
 | 
			
		||||
                eb.AddField(GetText(strs.cards), count.ToString(), true);
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
            await using var imageStream = await img.ToStreamAsync();
 | 
			
		||||
            await ctx.Channel.SendFileAsync(imageStream,
 | 
			
		||||
                imgName,
 | 
			
		||||
@@ -84,7 +85,7 @@ public partial class Gambling
 | 
			
		||||
            var cardBytes = await File.ReadAllBytesAsync($"data/images/cards/{cardName}.jpg");
 | 
			
		||||
            return Image.Load<Rgba32>(cardBytes);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        private async Task<Image<Rgba32>> GetCardImageAsync(Deck.Card currentCard)
 | 
			
		||||
        {
 | 
			
		||||
            var cardName = currentCard.ToString().ToLowerInvariant().Replace(' ', '_');
 | 
			
		||||
@@ -98,7 +99,7 @@ public partial class Gambling
 | 
			
		||||
        {
 | 
			
		||||
            if (num < 1)
 | 
			
		||||
                return;
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            if (num > 10)
 | 
			
		||||
                num = 10;
 | 
			
		||||
 | 
			
		||||
@@ -110,7 +111,7 @@ public partial class Gambling
 | 
			
		||||
        {
 | 
			
		||||
            if (num < 1)
 | 
			
		||||
                return;
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            if (num > 10)
 | 
			
		||||
                num = 10;
 | 
			
		||||
 | 
			
		||||
@@ -136,19 +137,29 @@ public partial class Gambling
 | 
			
		||||
 | 
			
		||||
        [Cmd]
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        public Task BetDraw([OverrideTypeReader(typeof(BalanceTypeReader))] long amount, InputValueGuess val, InputColorGuess? col = null)
 | 
			
		||||
        public Task BetDraw(
 | 
			
		||||
            [OverrideTypeReader(typeof(BalanceTypeReader))]
 | 
			
		||||
            long amount,
 | 
			
		||||
            InputValueGuess val,
 | 
			
		||||
            InputColorGuess? col = null)
 | 
			
		||||
            => BetDrawInternal(amount, val, col);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        [Cmd]
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        public Task BetDraw([OverrideTypeReader(typeof(BalanceTypeReader))] long amount, InputColorGuess col, InputValueGuess? val = null)
 | 
			
		||||
        public Task BetDraw(
 | 
			
		||||
            [OverrideTypeReader(typeof(BalanceTypeReader))]
 | 
			
		||||
            long amount,
 | 
			
		||||
            InputColorGuess col,
 | 
			
		||||
            InputValueGuess? val = null)
 | 
			
		||||
            => BetDrawInternal(amount, val, col);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        public async Task BetDrawInternal(long amount, InputValueGuess? val, InputColorGuess? col)
 | 
			
		||||
        {
 | 
			
		||||
            if (amount <= 0)
 | 
			
		||||
            if (!await CheckBetMandatory(amount))
 | 
			
		||||
            {
 | 
			
		||||
                return;
 | 
			
		||||
            
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var res = await _service.BetDrawAsync(ctx.User.Id,
 | 
			
		||||
                amount,
 | 
			
		||||
                (byte?)val,
 | 
			
		||||
@@ -161,13 +172,13 @@ public partial class Gambling
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var eb = _sender.CreateEmbed()
 | 
			
		||||
                .WithOkColor()
 | 
			
		||||
                .WithAuthor(ctx.User)
 | 
			
		||||
                .WithDescription(result.Card.GetEmoji())
 | 
			
		||||
                .AddField(GetText(strs.guess), GetGuessInfo(val, col), true)
 | 
			
		||||
                .AddField(GetText(strs.card), GetCardInfo(result.Card), true)
 | 
			
		||||
                .AddField(GetText(strs.won), N((long)result.Won), false)
 | 
			
		||||
                .WithImageUrl("attachment://card.png");
 | 
			
		||||
                            .WithOkColor()
 | 
			
		||||
                            .WithAuthor(ctx.User)
 | 
			
		||||
                            .WithDescription(result.Card.GetEmoji())
 | 
			
		||||
                            .AddField(GetText(strs.guess), GetGuessInfo(val, col), true)
 | 
			
		||||
                            .AddField(GetText(strs.card), GetCardInfo(result.Card), true)
 | 
			
		||||
                            .AddField(GetText(strs.won), N((long)result.Won), false)
 | 
			
		||||
                            .WithImageUrl("attachment://card.png");
 | 
			
		||||
 | 
			
		||||
            using var img = await GetCardImageAsync(result.Card);
 | 
			
		||||
            await using var imgStream = await img.ToStreamAsync();
 | 
			
		||||
@@ -189,9 +200,10 @@ public partial class Gambling
 | 
			
		||||
                InputColorGuess.Black => "B ⚫",
 | 
			
		||||
                _ => "❓"
 | 
			
		||||
            };
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            return $"{val} / {col}";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string GetCardInfo(RegularCard card)
 | 
			
		||||
        {
 | 
			
		||||
            var val = (int)card.Value switch
 | 
			
		||||
@@ -208,7 +220,7 @@ public partial class Gambling
 | 
			
		||||
                    RegularSuit.Diamonds or RegularSuit.Hearts => "R 🔴",
 | 
			
		||||
                    _ => "B ⚫"
 | 
			
		||||
                };
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            return $"{val} / {col}";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,8 @@ public partial class ResponseBuilder
 | 
			
		||||
        private readonly DiscordSocketClient _client;
 | 
			
		||||
        private int currentPage;
 | 
			
		||||
        
 | 
			
		||||
        private NadekoButtonInteractionHandler left;
 | 
			
		||||
        private NadekoButtonInteractionHandler right;
 | 
			
		||||
        private NadekoButtonInteractionHandler? left;
 | 
			
		||||
        private NadekoButtonInteractionHandler? right;
 | 
			
		||||
        private NadekoInteractionBase? extra;
 | 
			
		||||
 | 
			
		||||
        public PaginationSender(
 | 
			
		||||
@@ -120,8 +120,8 @@ public partial class ResponseBuilder
 | 
			
		||||
                if (_paginationBuilder.AddPaginatedFooter)
 | 
			
		||||
                    toSend.AddPaginatedFooter(currentPage, lastPage);
 | 
			
		||||
 | 
			
		||||
                left.SetCompleted();
 | 
			
		||||
                right.SetCompleted();
 | 
			
		||||
                left?.SetCompleted();
 | 
			
		||||
                right?.SetCompleted();
 | 
			
		||||
                extra?.SetCompleted();
 | 
			
		||||
                (left, extra, right) = (await GetInteractions());
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1400,4 +1400,6 @@ stickyroles:
 | 
			
		||||
cleanupguilddata:
 | 
			
		||||
  - cleanupguilddata
 | 
			
		||||
prompt:
 | 
			
		||||
  - prompt
 | 
			
		||||
  - prompt
 | 
			
		||||
honeypot:
 | 
			
		||||
  - honeypot
 | 
			
		||||
@@ -4523,4 +4523,12 @@ prompt:
 | 
			
		||||
  params:
 | 
			
		||||
    - query:
 | 
			
		||||
        desc: "The message to send to the bot."
 | 
			
		||||
    
 | 
			
		||||
honeypot:
 | 
			
		||||
  desc: |-
 | 
			
		||||
    Toggles honeypot on the current channel.
 | 
			
		||||
    Anyone sending a message in this channel will be soft banned. (Banned and then unbanned)
 | 
			
		||||
    This is useful for automatically getting rid of spam bots.
 | 
			
		||||
  ex:
 | 
			
		||||
    - ''
 | 
			
		||||
  params:
 | 
			
		||||
    - {}
 | 
			
		||||
@@ -1101,5 +1101,7 @@
 | 
			
		||||
  "todo_archived_list": "Archived Todo List",
 | 
			
		||||
  "search_results": "Search results",
 | 
			
		||||
  "queue_search_results": "Type the number of the search result to queue up that track.",
 | 
			
		||||
  "overloads": "Overloads"
 | 
			
		||||
  "overloads": "Overloads",
 | 
			
		||||
  "honeypot_on": "Honeypot enabled on this channel." ,
 | 
			
		||||
  "honeypot_off": "Honeypot disabled."
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user