server specific feature
the funny nickname command server list is no-longer hardcoded
This commit is contained in:
@@ -15,5 +15,6 @@ namespace Kehyeedra3
|
||||
public DbSet<User.BattleFishObject> Battlefish { get; set; }
|
||||
public DbSet<Mining> Mining { get; set; }
|
||||
public DbSet<Farming> Farming { get; set; }
|
||||
public DbSet<Guild> Guilds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +180,58 @@ namespace Kehyeedra3.Commands
|
||||
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid type.");
|
||||
}
|
||||
}
|
||||
[RequireRolePrecondition(AccessLevel.ServerAdmin)]
|
||||
[Command("enable"),Summary("Enable a bot feature on this server.")]
|
||||
public async Task EnableServerFeature(string feature)
|
||||
{
|
||||
using var Database = new ApplicationDbContextFactory().CreateDbContext();
|
||||
var guild = Database.Guilds.FirstOrDefault(x => x.Id == Context.Guild.Id);
|
||||
if (guild == null)
|
||||
{
|
||||
guild = new Guild
|
||||
{
|
||||
Id = Context.Guild.Id
|
||||
};
|
||||
Database.Guilds.Add(guild);
|
||||
}
|
||||
switch (feature.ToLower())
|
||||
{
|
||||
case "changenick":
|
||||
{
|
||||
guild.Changenick = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
await Database.SaveChangesAsync();
|
||||
await ReplyAsync($"{Context.User.Mention}\nEnabled {feature}");
|
||||
|
||||
}
|
||||
|
||||
[RequireRolePrecondition(AccessLevel.ServerAdmin)]
|
||||
[Command("disable"), Summary("Disable a bot feature on this server.")]
|
||||
public async Task DisableServerFeature(string feature)
|
||||
{
|
||||
using var Database = new ApplicationDbContextFactory().CreateDbContext();
|
||||
var guild = Database.Guilds.FirstOrDefault(x => x.Id == Context.Guild.Id);
|
||||
if (guild == null)
|
||||
{
|
||||
guild = new Guild
|
||||
{
|
||||
Id = Context.Guild.Id
|
||||
};
|
||||
Database.Guilds.Add(guild);
|
||||
}
|
||||
switch (feature.ToLower())
|
||||
{
|
||||
case "changenick":
|
||||
{
|
||||
guild.Changenick = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
await Database.SaveChangesAsync();
|
||||
await ReplyAsync($"{Context.User.Mention}\nDisabled {feature}");
|
||||
}
|
||||
|
||||
|
||||
// test commands
|
||||
|
||||
@@ -381,14 +381,21 @@ namespace Kehyeedra3.Commands
|
||||
[Command("changenick")]
|
||||
public async Task ChangeNickname(IGuildUser usr = null, [Remainder]string name = null)
|
||||
{
|
||||
if (Context.Guild.Id != 691361760300761139 && Context.Guild.Id != 912778610300039198)
|
||||
using var Database = new ApplicationDbContextFactory().CreateDbContext();
|
||||
var guild = Database.Guilds.FirstOrDefault(x => x.Id == Context.Guild.Id);
|
||||
if (guild == null)
|
||||
{
|
||||
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nWrong server retard");
|
||||
return;
|
||||
guild = new Guild
|
||||
{
|
||||
Id = Context.Guild.Id
|
||||
};
|
||||
Database.Guilds.Add(guild);
|
||||
}
|
||||
if (guild.Changenick)
|
||||
{
|
||||
if (usr == null || usr == Context.User || name == null)
|
||||
{
|
||||
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYeah you gotta ping someone and write a name, retard");
|
||||
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYeah you gotta ping someone else and write a name, retard");
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -397,6 +404,13 @@ namespace Kehyeedra3.Commands
|
||||
await usr.ModifyAsync(x => x.Nickname = $"{name}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyAsync($"{Context.User.Mention}\nServer admins can enable this command using 'enable changenick'.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<PackageReference Include="Discord.Net.Labs.Webhook" Version="2.3.3" />
|
||||
<PackageReference Include="Discord.Net.Labs.WebSocket" Version="2.3.9-pre" />
|
||||
<PackageReference Include="dotenv.net" Version="2.1.3" />
|
||||
<PackageReference Include="LostTech.TensorFlow.GPT" Version="0.1.0" />
|
||||
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="7.23.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
308
Kehyeedra3/Migrations/20220219105127_GuildFeatures.Designer.cs
generated
Normal file
308
Kehyeedra3/Migrations/20220219105127_GuildFeatures.Designer.cs
generated
Normal file
@@ -0,0 +1,308 @@
|
||||
// <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("20220219105127_GuildFeatures")]
|
||||
partial class GuildFeatures
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "3.1.11")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.Farming", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("CropInventory")
|
||||
.HasColumnType("LONGTEXT");
|
||||
|
||||
b.Property<int>("EmployeeCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<ulong>("FXp")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("Lvl")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("PlotInventory")
|
||||
.HasColumnType("LONGTEXT");
|
||||
|
||||
b.Property<ulong>("TXp")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<int>("Tier")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<ulong>("Xp")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Farming");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("FXp")
|
||||
.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<int>("Prestige")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<byte>("RodOwned")
|
||||
.HasColumnType("tinyint unsigned");
|
||||
|
||||
b.Property<byte>("RodUsed")
|
||||
.HasColumnType("tinyint 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.Guild", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<bool>("Changenick")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Guilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b =>
|
||||
{
|
||||
b.Property<ulong>("OfferId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<ulong>("BuyerId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<bool>("IsPurchaseFromStore")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsSellOffer")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<ulong>("ItemId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<int>("OfferAmount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<ulong?>("StoreFrontId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("StoreId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.HasKey("OfferId");
|
||||
|
||||
b.HasIndex("StoreFrontId");
|
||||
|
||||
b.ToTable("ItemOffer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.Mining", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("LastMine")
|
||||
.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("Mining");
|
||||
});
|
||||
|
||||
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<sbyte>("CurrentBattlefish")
|
||||
.HasColumnType("TINYINT");
|
||||
|
||||
b.Property<string>("GeneralInventory")
|
||||
.HasColumnType("LONGTEXT");
|
||||
|
||||
b.Property<long>("Money")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<ulong>("OwnerId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.User+BattleFishObject", b =>
|
||||
{
|
||||
b.Property<ulong>("FishId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<sbyte>("FishType")
|
||||
.HasColumnType("TINYINT");
|
||||
|
||||
b.Property<int>("Lvl")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.Property<ulong>("NextXp")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("UserId")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<ulong>("Xp")
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.HasKey("FishId");
|
||||
|
||||
b.ToTable("Battlefish");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b =>
|
||||
{
|
||||
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)
|
||||
.WithMany("Offers")
|
||||
.HasForeignKey("StoreFrontId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
|
||||
{
|
||||
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)
|
||||
.WithMany("Items")
|
||||
.HasForeignKey("StoreFrontId");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Kehyeedra3/Migrations/20220219105127_GuildFeatures.cs
Normal file
30
Kehyeedra3/Migrations/20220219105127_GuildFeatures.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Kehyeedra3.Migrations
|
||||
{
|
||||
public partial class GuildFeatures : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Guilds",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<ulong>(nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Changenick = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Guilds", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Guilds");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,20 @@ namespace Kehyeedra3.Migrations
|
||||
b.ToTable("Fishing");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.Guild", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint unsigned");
|
||||
|
||||
b.Property<bool>("Changenick")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Guilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b =>
|
||||
{
|
||||
b.Property<ulong>("OfferId")
|
||||
|
||||
17
Kehyeedra3/Services/Models/Guild.cs
Normal file
17
Kehyeedra3/Services/Models/Guild.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Kehyeedra3.Services.Models
|
||||
{
|
||||
class Guild
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; } = 0;
|
||||
public bool Changenick { get; set; } = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user