store progress and fishing fixes

also some other stuff
master
Lan 5 years ago
parent 9f81cf405c
commit 8b17cdf677
  1. 1
      Kehyeedra3/ApplicationDbContext.cs
  2. 12
      Kehyeedra3/Bot.cs
  3. 4
      Kehyeedra3/Command handler.cs
  4. 261
      Kehyeedra3/Commands.cs
  5. 22
      Kehyeedra3/Extensions.cs
  6. 1
      Kehyeedra3/Kehyeedra3.csproj
  7. 145
      Kehyeedra3/Migrations/20200330063400_store.Designer.cs
  8. 61
      Kehyeedra3/Migrations/20200330063400_store.cs
  9. 50
      Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs
  10. 12
      Kehyeedra3/Services/Models/Store.cs
  11. 2
      Kehyeedra3/Services/ReminderService.cs

@ -11,5 +11,6 @@ namespace Kehyeedra3
public DbSet<User> Users { get; set; } public DbSet<User> Users { get; set; }
public DbSet<Reminder> Reminders { get; set; } public DbSet<Reminder> Reminders { get; set; }
public DbSet<Fishing> Fishing { get; set; } public DbSet<Fishing> Fishing { get; set; }
public DbSet<StoreFront> StoreFronts { get; set; }
} }
} }

@ -11,20 +11,20 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using Kehyeedra3.Services; using Kehyeedra3.Services;
using System.Threading; using System.Threading;
using Discord.Addons.Interactive;
namespace Kehyeedra3 namespace Kehyeedra3
{ {
public class Bot public class Bot
{ {
/// Star Vars /// Star Vars
public static DiscordShardedClient _bot; public static DiscordSocketClient _bot;
public static System.Timers.Timer Clockboy; public static System.Timers.Timer Clockboy;
public static CommandService commands; public static CommandService commands;
public static AudioService AudioService; public static AudioService AudioService;
public static CommandService _cmds; public static CommandService _cmds;
public static IServiceProvider _dmap; public static IServiceProvider _dmap;
public static CommandServiceConfig _cmdsconfig; public static CommandServiceConfig _cmdsconfig;
public static int Shards = 0;
public static Random _rnd = new Random(); public static Random _rnd = new Random();
public static AIMLbot.Bot ChatService; public static AIMLbot.Bot ChatService;
public static AIMLbot.User ChatUser; public static AIMLbot.User ChatUser;
@ -60,19 +60,16 @@ namespace Kehyeedra3
WeebClient = new WebClient(); WeebClient = new WebClient();
_bot = new DiscordShardedClient(new DiscordSocketConfig() _bot = new DiscordSocketClient(new DiscordSocketConfig()
{ {
LogLevel = LogSeverity.Verbose, LogLevel = LogSeverity.Verbose,
DefaultRetryMode = RetryMode.AlwaysRetry, DefaultRetryMode = RetryMode.AlwaysRetry,
HandlerTimeout = 10000, HandlerTimeout = 10000,
ConnectionTimeout = 10000, ConnectionTimeout = 10000
TotalShards = Config.Shards
}); });
AudioService = new AudioService(); AudioService = new AudioService();
Shards = _bot.Shards.Count;
_cmds = new CommandService(); _cmds = new CommandService();
_cmdsconfig = new CommandServiceConfig _cmdsconfig = new CommandServiceConfig
@ -84,6 +81,7 @@ namespace Kehyeedra3
.AddSingleton(_bot) .AddSingleton(_bot)
.AddSingleton(_cmds) .AddSingleton(_cmds)
.AddSingleton(AudioService) .AddSingleton(AudioService)
.AddSingleton(new InteractiveService(_bot, TimeSpan.FromSeconds(30)))
.BuildServiceProvider(); .BuildServiceProvider();
await CommandHandler.InstallCommands(); await CommandHandler.InstallCommands();

@ -98,7 +98,7 @@ namespace Kehyeedra3
var message = arg as SocketUserMessage; var message = arg as SocketUserMessage;
if (message == null) return; if (message == null) return;
int argPos = 0; int argPos = 0;
var context = new CommandContext(_bot, message); var context = new SocketCommandContext(_bot, message);
if (message.HasMentionPrefix(_bot.CurrentUser, ref argPos)) if (message.HasMentionPrefix(_bot.CurrentUser, ref argPos))
{ {
await KizunaAi(context, message.Content); await KizunaAi(context, message.Content);
@ -108,7 +108,7 @@ namespace Kehyeedra3
await context.Channel.SendMessageAsync($"B emoji detected. Proceed to kill yourself, {context.User.Mention}"); await context.Channel.SendMessageAsync($"B emoji detected. Proceed to kill yourself, {context.User.Mention}");
} }
var jrole = context.Guild.GetRole(375289794999091201); var jrole = context.Guild.GetRole(375289794999091201);
var euser = await context.Guild.GetUserAsync(context.User.Id).ConfigureAwait(false); var euser = context.Guild.GetUser(context.User.Id);
//var jas = await context.Guild.GetUserAsync(236952555265982464).ConfigureAwait(false); //var jas = await context.Guild.GetUserAsync(236952555265982464).ConfigureAwait(false);
//var cat = await context.Guild.GetUserAsync(194439970797256706).ConfigureAwait(false); //var cat = await context.Guild.GetUserAsync(194439970797256706).ConfigureAwait(false);
//if (euser.RoleIds.Any(id => id == 682109241363922965)) //if (euser.RoleIds.Any(id => id == 682109241363922965))

@ -13,6 +13,7 @@ using MySql.Data.MySqlClient;
using Kehyeedra3.Services.Models; using Kehyeedra3.Services.Models;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Internal;
using Discord.Addons.Interactive;
namespace Kehyeedra3 namespace Kehyeedra3
{ {
@ -23,7 +24,7 @@ namespace Kehyeedra3
public async Task Pong() public async Task Pong()
{ {
await Context.Channel.TriggerTypingAsync(); await Context.Channel.TriggerTypingAsync();
await ReplyAsync($"My current ping is {Bot._bot.GetShardFor(Context.Guild).Latency}ms"); await ReplyAsync($"My current ping is {Bot._bot.Latency}ms");
} }
} }
[Group] [Group]
@ -158,7 +159,7 @@ namespace Kehyeedra3
// await Bot.AudioService.SendAudioAsync(Context.Guild, Context.Channel, song); // await Bot.AudioService.SendAudioAsync(Context.Guild, Context.Channel, song);
// } // }
//} //}
public class Stuff : ModuleBase /////////////////////////////////////////////// public class Stuff : InteractiveBase<SocketCommandContext> ///////////////////////////////////////////////
{ {
[Command("delet")] [Command("delet")]
@ -276,9 +277,9 @@ namespace Kehyeedra3
[Command("grant")] [Command("grant")]
public async Task Daycare(IGuildUser ouser) public async Task Daycare(IGuildUser ouser)
{ {
var user = await Context.Guild.GetUserAsync(Context.User.Id).ConfigureAwait(false); var user = Context.Guild.GetUser(Context.User.Id);
var drole = Context.Guild.GetRole(682109241363922965); var drole = Context.Guild.GetRole(682109241363922965);
if (user.RoleIds.Any(id => id == 682109241363922965)) if (user.Roles.Any(x => x.Id == 682109241363922965))
{ {
await user.RemoveRoleAsync(drole); await user.RemoveRoleAsync(drole);
await ouser.AddRoleAsync(drole); await ouser.AddRoleAsync(drole);
@ -303,7 +304,7 @@ namespace Kehyeedra3
} }
} }
public class Economy : ModuleBase<ICommandContext> public class Economy : InteractiveBase<SocketCommandContext>
{ {
readonly string[] ores = new string[] readonly string[] ores = new string[]
{ {
@ -543,8 +544,7 @@ namespace Kehyeedra3
{ {
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList(); List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
weight = SRandom.Next(200, 4001); xp = 10;
xp = 100;
} }
else else
{ {
@ -576,6 +576,11 @@ namespace Kehyeedra3
FishSize size; FishSize size;
if (fish.Rarity == FishRarity.Legendary)
{
weight = 100;
}
if (weight >= 75) if (weight >= 75)
{ {
size = FishSize.Medium; size = FishSize.Medium;
@ -583,6 +588,17 @@ namespace Kehyeedra3
{ {
weight = SRandom.Next(1, 201); weight = SRandom.Next(1, 201);
} }
if (fish.Rarity == FishRarity.Legendary)
{
weight = SRandom.Next(200 + Convert.ToInt32(level*2), 4001);
}
if (weight > 50)
{
double w = Convert.ToDouble(weight);
xp += Convert.ToUInt64(Math.Round((xp * w / 100), 0, MidpointRounding.ToEven));
}
} }
else else
{ {
@ -725,14 +741,14 @@ namespace Kehyeedra3
if (user.Id != Context.User.Id) if (user.Id != Context.User.Id)
{ {
await Context.Channel.SendMessageAsync($"FEESH INVENTOGleS of {user.Mention}"); await Context.Channel.SendMessageAsync($"arr matey this be {user.Mention}'s locker");
} }
if(small.Any()) if(small.Any())
{ {
EmbedBuilder embed = new EmbedBuilder EmbedBuilder embed = new EmbedBuilder
{ {
Title = "SMONKL FEESH" Title = "small mateys"
}; };
foreach (var entry in small) foreach (var entry in small)
@ -754,7 +770,7 @@ namespace Kehyeedra3
{ {
EmbedBuilder embed = new EmbedBuilder EmbedBuilder embed = new EmbedBuilder
{ {
Title = "MED FEESH" Title = "medium mateys"
}; };
foreach (var entry in med) foreach (var entry in med)
@ -777,7 +793,7 @@ namespace Kehyeedra3
{ {
EmbedBuilder embed = new EmbedBuilder EmbedBuilder embed = new EmbedBuilder
{ {
Title = "LARG FEESH" Title = "large mateys"
}; };
foreach (var entry in large) foreach (var entry in large)
@ -800,98 +816,145 @@ namespace Kehyeedra3
await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false); await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false);
} }
} }
[Command("buy")] //[Command("tradebuy", RunMode = RunMode.Async)]
public async Task TradingBuy(int amount, string itemtype, int price, [Remainder] string item) //public async Task TradingBuy(int amount, string itemtype, int price, [Remainder] string item)
{ //{
string contents = "trade info"; // using (var Database = new ApplicationDbContextFactory().CreateDbContext())
FishSize size = 0; // {
FishSpecies species = 0; // var KehUser = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id);
List<Fish> fishes = Fishing.GetFishList(); // if (itemtype.ToLowerInvariant() == "fish")
if (itemtype.ToLowerInvariant() == "fish") // {
{ // FishSize size = 0;
if (item.ToLowerInvariant().Contains("large")) // FishSpecies species = 0;
{ // List<Fish> fishes = Fishing.GetFishList();
size = FishSize.Large;
}
else if (item.ToLowerInvariant().Contains("medium"))
{
size = FishSize.Medium;
}
else if (item.ToLowerInvariant().Contains("small"))
{
size = FishSize.Small;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards.");
return;
}
if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())))
{
species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish.");
return;
}
contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price/10000d}%\n";
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to buy item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false); // if (item.ToLowerInvariant().Contains("large"))
// {
// size = FishSize.Large;
// }
// else if (item.ToLowerInvariant().Contains("medium"))
// {
// size = FishSize.Medium;
// }
// else if (item.ToLowerInvariant().Contains("small"))
// {
// size = FishSize.Small;
// }
// else
// {
// await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards.");
// return;
// }
await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false); // if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())))
} // {
else // species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id;
{ // }
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false); // else
} // {
} // await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish.");
[Command("sell")] // return;
public async Task TradingSell(int amount, string itemtype, int price, [Remainder] string item) // }
{
string contents = "trade info";
FishSize size = 0;
FishSpecies species = 0;
List<Fish> fishes = Fishing.GetFishList();
if (itemtype.ToLowerInvariant() == "fish")
{
if (item.ToLowerInvariant().Contains("large"))
{
size = FishSize.Large;
}
else if (item.ToLowerInvariant().Contains("medium"))
{
size = FishSize.Medium;
}
else if (item.ToLowerInvariant().Contains("small"))
{
size = FishSize.Small;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards.");
return;
}
if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())))
{
species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish.");
return;
}
contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price / 10000d}%\n";
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to sell item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false); // if (Database.StoreFronts.Any(x=> x.StoreItemType == StoreItemType.Fish))
// {
// var stores = Database.StoreFronts.Where(x => x.StoreItemType == StoreItemType.Fish).ToList();
// stores.Shuffle();
// var store = stores.FirstOrDefault();
// if(store.Items.Any(x=>x.Item.ToLowerInvariant() == item.ToLowerInvariant()))
// {
// var itm = store.Items.FirstOrDefault(x => x.Item.ToLowerInvariant() == item.ToLowerInvariant());
// if(itm.Price * amount <= KehUser.Money)
// {
// if (itm.Amount >= amount)
// {
// await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to buy item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false);
// }
// else
// {
// await ReplyAsync("Whoa slow down there buckaroo, they ain't selling that much, go sit in the corner and think about what you've done").ConfigureAwait(false);
// }
// }
// else
// {
// await ReplyAsync("Nigger slow down, you aint got the cash monee to make that purchase smh frfr onjah").ConfigureAwait(false);
// }
// }
// }
// else
// {
// await ReplyAsync("No one is selling, so you can't buy lmao, big stinky");
// }
// }
// else
// {
// await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false);
// }
// }
//}
//[Command("tradesell")]
//public async Task TradingSell(int amount, string itemtype, int price, [Remainder] string item)
//{
// string contents = "trade info";
// FishSize size = 0;
// FishSpecies species = 0;
// List<Fish> fishes = Fishing.GetFishList();
// if (itemtype.ToLowerInvariant() == "fish")
// {
// if (item.ToLowerInvariant().Contains("large"))
// {
// size = FishSize.Large;
// }
// else if (item.ToLowerInvariant().Contains("medium"))
// {
// size = FishSize.Medium;
// }
// else if (item.ToLowerInvariant().Contains("small"))
// {
// size = FishSize.Small;
// }
// else
// {
// await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards.");
// return;
// }
// if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())))
// {
// species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id;
// }
// else
// {
// await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish.");
// return;
// }
// contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price / 10000d}%\n";
// await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to sell item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false);
// await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false);
// }
// else
// {
// await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false);
// }
//}
//[Command("tradeoffers")]
//public async Task ShowOffers(bool localOffers = true)
//{
// using (var database = new ApplicationDbContextFactory().CreateDbContext())
// {
// string message = "";
// if (localOffers)
// {
// }
// }
//}
await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false);
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false);
}
}
[Command("balance"),Alias("bal","money")] [Command("balance"),Alias("bal","money")]
public async Task Shekels([Remainder] IUser otherUser = null) public async Task Shekels([Remainder] IUser otherUser = null)
{ {

@ -1,4 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Security.Cryptography;
namespace Kehyeedra3 namespace Kehyeedra3
{ {
@ -11,5 +13,25 @@ namespace Kehyeedra3
public static DateTime FromYeedraStamp(this ulong time) public static DateTime FromYeedraStamp(this ulong time)
=> YeedraTime.AddSeconds(Convert.ToDouble(time)); => YeedraTime.AddSeconds(Convert.ToDouble(time));
//https://stackoverflow.com/a/1262619
public static void Shuffle<T>(this IList<T> list)
{
using (RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider())
{
int n = list.Count;
while (n > 1)
{
byte[] box = new byte[1];
do provider.GetBytes(box);
while (!(box[0] < n * (byte.MaxValue / n)));
int k = (box[0] % n);
n--;
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}
} }
} }

@ -6,6 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Discord.Addons.Interactive" Version="1.0.1" />
<PackageReference Include="Discord.Net" Version="2.1.1" /> <PackageReference Include="Discord.Net" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">

@ -0,0 +1,145 @@
// <auto-generated />
using System;
using Kehyeedra3;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kehyeedra3.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200330063400_store")]
partial class store
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.1")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<string>("Inventory")
.HasColumnType("LONGTEXT");
b.Property<ulong>("LastFish")
.HasColumnType("bigint unsigned");
b.Property<ulong>("Lvl")
.HasColumnType("bigint unsigned");
b.Property<ulong>("TXp")
.HasColumnType("bigint unsigned");
b.Property<ulong>("Xp")
.HasColumnType("bigint unsigned");
b.HasKey("Id");
b.ToTable("Fishing");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.Reminder", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<ulong>("Created")
.HasColumnType("bigint unsigned");
b.Property<string>("Message")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<ulong>("Send")
.HasColumnType("bigint unsigned");
b.Property<ulong>("UserId")
.HasColumnType("bigint unsigned");
b.HasKey("Id");
b.ToTable("Reminders");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreFront", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("StoreItemType")
.HasColumnType("int");
b.Property<ulong>("UserId")
.HasColumnType("bigint unsigned");
b.HasKey("Id");
b.ToTable("StoreFronts");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
{
b.Property<ulong>("InvId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("Amount")
.HasColumnType("int");
b.Property<string>("Item")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("Price")
.HasColumnType("int");
b.Property<ulong?>("StoreFrontId")
.HasColumnType("bigint unsigned");
b.HasKey("InvId");
b.HasIndex("StoreFrontId");
b.ToTable("StoreInventory");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.User", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<string>("Avatar")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<ulong>("LastMine")
.HasColumnType("bigint unsigned");
b.Property<long>("Money")
.HasColumnType("bigint");
b.Property<string>("Username")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
{
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)
.WithMany("Items")
.HasForeignKey("StoreFrontId");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,61 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Kehyeedra3.Migrations
{
public partial class store : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "StoreFronts",
columns: table => new
{
Id = table.Column<ulong>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<ulong>(nullable: false),
StoreItemType = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StoreFronts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "StoreInventory",
columns: table => new
{
InvId = table.Column<ulong>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Item = table.Column<string>(nullable: true),
Amount = table.Column<int>(nullable: false),
Price = table.Column<int>(nullable: false),
StoreFrontId = table.Column<ulong>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_StoreInventory", x => x.InvId);
table.ForeignKey(
name: "FK_StoreInventory_StoreFronts_StoreFrontId",
column: x => x.StoreFrontId,
principalTable: "StoreFronts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_StoreInventory_StoreFrontId",
table: "StoreInventory",
column: "StoreFrontId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "StoreInventory");
migrationBuilder.DropTable(
name: "StoreFronts");
}
}
}

@ -1,4 +1,5 @@
// <auto-generated /> // <auto-generated />
using System;
using Kehyeedra3; using Kehyeedra3;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
@ -65,6 +66,48 @@ namespace Kehyeedra3.Migrations
b.ToTable("Reminders"); b.ToTable("Reminders");
}); });
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreFront", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("StoreItemType")
.HasColumnType("int");
b.Property<ulong>("UserId")
.HasColumnType("bigint unsigned");
b.HasKey("Id");
b.ToTable("StoreFronts");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
{
b.Property<ulong>("InvId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("Amount")
.HasColumnType("int");
b.Property<string>("Item")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("Price")
.HasColumnType("int");
b.Property<ulong?>("StoreFrontId")
.HasColumnType("bigint unsigned");
b.HasKey("InvId");
b.HasIndex("StoreFrontId");
b.ToTable("StoreInventory");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.User", b => modelBuilder.Entity("Kehyeedra3.Services.Models.User", b =>
{ {
b.Property<ulong>("Id") b.Property<ulong>("Id")
@ -87,6 +130,13 @@ namespace Kehyeedra3.Migrations
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
{
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)
.WithMany("Items")
.HasForeignKey("StoreFrontId");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

@ -1,11 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Kehyeedra3.Services.Models namespace Kehyeedra3.Services.Models
{ {
public class StoreFront public class StoreFront
{ {
public ulong Id { get; set; } = 0; [Key]
public ulong Id { get; set; }
public ulong UserId { get; set; } = 0; public ulong UserId { get; set; } = 0;
public StoreItemType StoreItemType { get; set; } = 0; public StoreItemType StoreItemType { get; set; } = 0;
@ -20,9 +22,8 @@ namespace Kehyeedra3.Services.Models
public class StoreInventory public class StoreInventory
{ {
public ulong ItemId { get; set; } = 0; [Key]
public ulong UserId { get; set; } = 0; public ulong InvId { get; set; }
public StoreItemType StoreItemType { get; set; } = 0;
public string Item { get; set; } = ""; public string Item { get; set; } = "";
public int Amount { get; set; } = 0; public int Amount { get; set; } = 0;
public int Price { get; set; } = 0; public int Price { get; set; } = 0;
@ -30,14 +31,15 @@ namespace Kehyeedra3.Services.Models
public class ItemOffer public class ItemOffer
{ {
[Key]
public ulong OfferId { get; set; } public ulong OfferId { get; set; }
public ulong BuyerId { get; set; } public ulong BuyerId { get; set; }
public ulong StoreId { get; set; } public ulong StoreId { get; set; }
public StoreItemType StoreType { get; set; }
public ulong ItemId { get; set; } public ulong ItemId { get; set; }
public int Amount { get; set; } public int Amount { get; set; }
public int OfferAmount { get; set; } public int OfferAmount { get; set; }
public bool IsPurchaseFromStore { get; set; } public bool IsPurchaseFromStore { get; set; }
public bool IsSellOffer { get; set; } = false;
} }
public static class StoreUtilities public static class StoreUtilities

@ -20,7 +20,7 @@ namespace Kehyeedra3.Services
List<Reminder> toRemove = new List<Reminder>(); List<Reminder> toRemove = new List<Reminder>();
while (true) while (true)
{ {
if(Database.Reminders.Any() && Bot._bot != null && Bot._bot.Shards.All(x=>x.ConnectionState == Discord.ConnectionState.Connected)) if(Database.Reminders.Any() && Bot._bot != null && Bot._bot.ConnectionState == Discord.ConnectionState.Connected)
{ {
foreach(var x in Database.Reminders) foreach(var x in Database.Reminders)
{ {

Loading…
Cancel
Save