public async void AddPremiumPlayerAsync(string ip, Guid guid)
{
await Connection.OpenAsync();
// Check if the player already has an entry
SQLiteCommand command = new SQLiteCommand("SELECT COUNT(*) FROM premium WHERE GUID = $guid");
command.Parameters.AddWithValue("$guid", guid.ToString("N"));
long count = (long)await ExecuteScalarAsync(command);
if (count == 1)
{
command = new SQLiteCommand("UPDATE premium SET ip = $ip, timestamp = datetime('now') WHERE GUID = $guid");
command.Parameters.AddWithValue("$guid", guid.ToString("N"));
command.Parameters.AddWithValue("$ip", ip);
command.Connection = Connection;
await command.ExecuteNonQueryAsync();
}
else
{
command = new SQLiteCommand("INSERT INTO premium(IP, GUID) VALUES ($ip, $guid)");
command.Parameters.AddWithValue("$guid", guid.ToString("N"));
command.Parameters.AddWithValue("$ip", ip);
command.Connection = Connection;
await command.ExecuteNonQueryAsync();
}
Connection.Close();
}