mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
- Minor changes - Escape kick reason @poggu suggestion - Auto-updater for config - Using UTC time - Added expiring IP bans after x days (`ExpireOldIpBans` in config => value = days, 0 = disabled) - Added exception message to database error - Fixed? ungag/unmute/unsilence commands - Updated css version to `178` - Changed `css_adminhelp` command to use new file `admin_help.txt` as output
31 lines
646 B
C#
31 lines
646 B
C#
using Microsoft.Extensions.Logging;
|
|
using MySqlConnector;
|
|
|
|
namespace CS2_SimpleAdmin
|
|
{
|
|
public class Database
|
|
{
|
|
private readonly string _dbConnectionString;
|
|
|
|
public Database(string dbConnectionString)
|
|
{
|
|
_dbConnectionString = dbConnectionString;
|
|
}
|
|
|
|
public async Task<MySqlConnection> GetConnectionAsync()
|
|
{
|
|
try
|
|
{
|
|
var connection = new MySqlConnection(_dbConnectionString);
|
|
await connection.OpenAsync();
|
|
return connection;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (CS2_SimpleAdmin._logger != null)
|
|
CS2_SimpleAdmin._logger.LogCritical($"Unable to connect to database: {ex.Message}");
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
} |