a logolás külön fájlba került
This commit is contained in:
parent
f680dd869b
commit
e97a4e7a66
2 changed files with 25 additions and 10 deletions
22
logger.cs
Normal file
22
logger.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace T3k3rg0
|
||||||
|
{
|
||||||
|
public static class Logger
|
||||||
|
{
|
||||||
|
public static ILoggerFactory CreateLoggerFactory()
|
||||||
|
{
|
||||||
|
return LoggerFactory.Create(builder =>
|
||||||
|
{
|
||||||
|
builder
|
||||||
|
.AddSimpleConsole(options =>
|
||||||
|
{
|
||||||
|
options.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] ";
|
||||||
|
options.SingleLine = true;
|
||||||
|
options.ColorBehavior = Microsoft.Extensions.Logging.Console.LoggerColorBehavior.Enabled;
|
||||||
|
})
|
||||||
|
.SetMinimumLevel(LogLevel.Debug);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
program.cs
13
program.cs
|
|
@ -13,17 +13,15 @@ namespace T3k3rg0
|
||||||
{
|
{
|
||||||
Env.Load(); // .env fájl betöltése
|
Env.Load(); // .env fájl betöltése
|
||||||
|
|
||||||
|
var loggerFactory = Logger.CreateLoggerFactory();
|
||||||
|
|
||||||
var discord = new DiscordClient(new DiscordConfiguration()
|
var discord = new DiscordClient(new DiscordConfiguration()
|
||||||
{
|
{
|
||||||
Token = Environment.GetEnvironmentVariable("DISCORD_BOT_TOKEN"),
|
Token = Environment.GetEnvironmentVariable("DISCORD_BOT_TOKEN"),
|
||||||
TokenType = TokenType.Bot,
|
TokenType = TokenType.Bot,
|
||||||
Intents = DiscordIntents.All,
|
Intents = DiscordIntents.All,
|
||||||
MinimumLogLevel = LogLevel.Debug,
|
MinimumLogLevel = LogLevel.Debug,
|
||||||
LoggerFactory = LoggerFactory.Create(builder =>
|
LoggerFactory = loggerFactory,
|
||||||
{
|
|
||||||
builder.AddConsole();
|
|
||||||
builder.SetMinimumLevel(LogLevel.Debug);
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
var commands = discord.UseCommandsNext(new CommandsNextConfiguration()
|
var commands = discord.UseCommandsNext(new CommandsNextConfiguration()
|
||||||
{
|
{
|
||||||
|
|
@ -35,11 +33,6 @@ namespace T3k3rg0
|
||||||
commands.RegisterCommands<Commands.Hello>();
|
commands.RegisterCommands<Commands.Hello>();
|
||||||
ReactionRoleHandler.Register(discord);
|
ReactionRoleHandler.Register(discord);
|
||||||
|
|
||||||
discord.Ready += async (s, e) =>
|
|
||||||
{
|
|
||||||
Console.WriteLine("T3k3rg0 elindult !");
|
|
||||||
};
|
|
||||||
|
|
||||||
await discord.ConnectAsync();
|
await discord.ConnectAsync();
|
||||||
await Task.Delay(-1);
|
await Task.Delay(-1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue