yeeted shit and added shit

removed databaseservice.cs due to useless
made changes to mine command
worked on fish command
pull/2/head
Lan 5 years ago
parent fc0948f74e
commit 6cff0b753b
  1. 1
      Kehyeedra3/ApplicationDbContext.cs
  2. 96
      Kehyeedra3/Commands.cs
  3. 183
      Kehyeedra3/Services/DatabaseService.cs
  4. 17
      Kehyeedra3/Services/Models/Fishing.cs

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

@ -150,7 +150,6 @@ namespace Kehyeedra3
//}
public class Stuff : ModuleBase ///////////////////////////////////////////////
{
//public DatabaseService dbService { get; set; }
[Command("delet")]
public async Task DeletThis()
@ -265,7 +264,7 @@ namespace Kehyeedra3
}
}
public class Money : ModuleBase<ICommandContext>
public class Economy : ModuleBase<ICommandContext>
{
readonly string[] ores = new string[]
{
@ -304,6 +303,7 @@ namespace Kehyeedra3
"**Copper**,",
"**Volatile Motes**,",
"a **Diamond**,",
"a **Girlfriend**,",
"**Thorium**,",
"a **Fresh Apple**,",
"**Raid Shadow Legends** sponsorship money,",
@ -329,6 +329,31 @@ namespace Kehyeedra3
"a **Can of Peaches**,",
"a **Used Deodorant Stick**,"
};
readonly string[] discards = new string[]
{
"you presume it is worthless and toss it away",
"you drop it and lose it",
"a vicious furry takes it from you",
"it appears to have vanished",
"but it seems like you were hallucinating",
"but it is seized by the communists",
"you mistake it for a chance to succeed in life and throw it away"
};
readonly string[] rfish = new string[]
{
"Clownfish",
"Doomfish"
};
readonly string[] ufish = new string[]
{
"Mantis Shrimp",
"Gigacrab"
};
readonly string[] cfish = new string[]
{
"Cod",
"Salmon"
};
readonly string o = "<:ye:677089325208305665>";
readonly string n = "<:no:677091514249248778>";
readonly string ye = "<:ya:677179974154715146>";
@ -353,7 +378,9 @@ namespace Kehyeedra3
int end = 0;
string marks = $"{n}{n}{n}";
int num = SRandom.Next(ores.Length);
int numd = SRandom.Next(discards.Length);
string ore = ores[num];
string discard = discards[numd];
if (res1 > 20)
{
end = 1;
@ -394,7 +421,7 @@ namespace Kehyeedra3
if (end == 0)
{
await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You have found {ore} you presume it is worthless and toss it away.");
await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You have found {ore} {discard}.");
}
else
{
@ -425,6 +452,69 @@ namespace Kehyeedra3
await Context.Channel.SendMessageAsync($"{Context.User.Mention} wait 1 minute ok next minute yeah? yeah buddy?");
}
}
[Command("fish")]
public async Task Fishing()
{
int rarity = SRandom.Next(0, 201);
int rarmult = 0;
string rar = "";
string fish = "";
if (rarity > 180)
{
rar = "*Rare*";
rarmult = 3;
int num = SRandom.Next(rfish.Length);
fish = rfish[num];
}
else
{
if (rarity > 120)
{
rar = "*Uncommon*";
rarmult = 2;
int num = SRandom.Next(ufish.Length);
fish = ufish[num];
}
else
{
if (rarity == 7)
{
rar = "***Glorious***";
rarmult = 7;
fish = "Lucky Catfish";
}
else
{
rar = "*Common*";
rarmult = 1;
int num = SRandom.Next(cfish.Length);
fish = cfish[num];
}
}
}
int weight = SRandom.Next(1, 201);
int size = 0;
if (weight > 150 || rarmult == 7)
{
size = 3;
}
else
{
if (weight > 100)
{
size = 2;
}
else
{
size = 1;
}
}
int value = size + rarmult;
await Context.Channel.SendMessageAsync($"You have caught a {weight/10d}kg **{fish}**, rarity: {rar}");
}
[Command("balance")]
public async Task Shekels([Remainder] IUser otherUser = null)
{

@ -1,183 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data;
using MySql.Data.MySqlClient;
using Kehyeedra3.Services.Models;
using Discord;
using System.Timers;
namespace Kehyeedra3.Services
{
public class DatabaseService
{/*
private readonly string ConnectionString;
private MySqlConnection Connection;
public DatabaseService(string host, ushort port, string user, string password, string database)
{
ConnectionString = $"Server={host};Port={port};Database={database};Uid={user};Pwd={password}";
}
private async Task ConnectOrCreateAsync()
{
if (Connection == null)
{
Connection = new MySqlConnection(ConnectionString);
}
if (Connection.State == System.Data.ConnectionState.Open)
return;
else
{
await Connection.OpenAsync();
return;
}
}
public async Task<bool> CreateUserAsync(IUser user)
{
await ConnectOrCreateAsync();
MySqlCommand command = new MySqlCommand("INSERT INTO `users` (UserID, Avatar, UName) VALUES (@uid, @avatar, @uname);"); //userinfo
command.Parameters.AddWithValue("@uid", user.Id);
command.Parameters.AddWithValue("@avatar", user.GetAvatarUrl());
command.Parameters.AddWithValue("@uname", user.Username);
command.Connection = Connection;
try
{
await command.ExecuteScalarAsync();
command.Dispose();
return true;
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
finally
{
command.Dispose();
}
return false;
}
public async Task<bool> DoesUserExistAsync(IUser user)
{
await ConnectOrCreateAsync();
var command = new MySqlCommand("SELECT 1 FROM `users` WHERE UserID = @userId;");
command.Connection = Connection;
command.Parameters.AddWithValue("@userId", user.Id);
return Convert.ToBoolean(await command.ExecuteScalarAsync());
}
public async Task<DatabaseUser> GetUserAsync(ulong userID)
{
var command = new MySqlCommand("SELECT * FROM `users` WHERE UserID = @userId;");
command.Connection = Connection;
command.Parameters.AddWithValue("@userId", userID);
var result = await command.ExecuteReaderAsync();
if (result.HasRows)
{
while(await result.ReadAsync())
{
return new DatabaseUser //userinfo
{
UserID = ulong.Parse(result["UserId"].ToString()),
Avatar = result["Avatar"].ToString(),
UName = result["UName"].ToString(),
};
}
}
return null;
}
public async Task<bool> CreateReminderAsync(ulong rUserID, string rMessage, ulong rSend)
{
await ConnectOrCreateAsync();
MySqlCommand command = new MySqlCommand("INSERT INTO `reminders` (UserID, RMessage, RSend) VALUES (@uid, @rmsg, @rsend);"); //reminderinfo
command.Parameters.AddWithValue("@uid", rUserID);
command.Parameters.AddWithValue("@rmsg", rMessage);
command.Parameters.AddWithValue("@rsend", rSend);
command.Connection = Connection;
try
{
await command.ExecuteScalarAsync();
command.Dispose();
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
command.Dispose();
}
return false;
}
public async Task<bool> DoesReminderExistAsync(IUser user)
{
await ConnectOrCreateAsync();
var command = new MySqlCommand("SELECT 1 FROM `reminders` WHERE UserID = @userId;");
command.Connection = Connection;
command.Parameters.AddWithValue("@userId", user.Id);
return Convert.ToBoolean(await command.ExecuteScalarAsync());
}
public async Task<DatabaseReminder> GetReminderAsync(ulong userID)
{
var command = new MySqlCommand("SELECT * FROM `reminders` WHERE UserID = @userId;");
command.Connection = Connection;
command.Parameters.AddWithValue("@userId", userID);
var result = await command.ExecuteReaderAsync();
if (result.HasRows)
{
while (await result.ReadAsync())
{
return new DatabaseReminder //reminderinfo
{
rUserID = ulong.Parse(result["rUserID"].ToString()),
rMessage = result["rMessage"].ToString(),
rSend = ulong.Parse(result["rSend"].ToString())
};
}
}
return null;
}
public async Task<List<DatabaseReminder>> GetAllReminderAsync()
{
var command = new MySqlCommand("SELECT * FROM `reminders`;");
command.Connection = Connection;
var Reminders = new List<DatabaseReminder>();
var result = await command.ExecuteReaderAsync();
if (result.HasRows)
{
while (await result.ReadAsync())
{
Reminders.Add (new DatabaseReminder //reminderinfo
{
rUserID = ulong.Parse(result["rUserID"].ToString()),
rMessage = result["rMessage"].ToString(),
rSend = ulong.Parse(result["rSend"].ToString())
});
}
return Reminders;
}
return null;
}
*/
}
}

@ -0,0 +1,17 @@
//namespace Kehyeedra3.Services.Models
//{
// class Fishing
// {
// public ulong UserId { get; set; } = 0;
// public ulong LastFish { get; set; } = 0;
// public ulong CFish { get; set; } = 0;
// public ulong CVal {get; set;} = 0;
// public ulong UFish { get; set; } = 0;
// public ulong UVal {get; set;} = 0;
// public ulong RFish { get; set; } = 0;
// public ulong RVal { get; set; } = 0;
// public ulong LFish { get; set; } = 0;
// public ulong LVal { get; set; } = 0;
// public ulong XP { get; set; } = 0;
// }
//}
Loading…
Cancel
Save