Dockerizes discord bot
This commit is contained in:
parent
7179c70463
commit
bcb05cd0c9
|
@ -9,6 +9,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net" Version="3.12.0" />
|
||||
<ProjectReference Include="..\..\Framework\ArgsUniform\ArgsUniform.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using ArgsUniform;
|
||||
|
||||
namespace BiblioTech
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
[Uniform("token", "t", "TOKEN", true, "Discord Application Token")]
|
||||
public string ApplicationToken { get; set; } = string.Empty;
|
||||
|
||||
[Uniform("deploys", "d", "DEPLOYS", false, "Path where deployment JSONs are located.")]
|
||||
public string DeploymentsPath { get; set; } = "deploys";
|
||||
}
|
||||
}
|
|
@ -1,29 +1,49 @@
|
|||
using Discord;
|
||||
using ArgsUniform;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
public class Program
|
||||
namespace BiblioTech
|
||||
{
|
||||
public static Task Main(string[] args) => new Program().MainAsync();
|
||||
|
||||
private DiscordSocketClient client;
|
||||
|
||||
public async Task MainAsync()
|
||||
public class Program
|
||||
{
|
||||
client = new DiscordSocketClient();
|
||||
private DiscordSocketClient client = null!;
|
||||
|
||||
client.Log += Log;
|
||||
public static Configuration Config { get; private set; } = null!;
|
||||
|
||||
// You can assign your bot token to a string, and pass that in to connect.
|
||||
// This is, however, insecure, particularly if you plan to have your code hosted in a public repository.
|
||||
var token = "token";
|
||||
public static Task Main(string[] args)
|
||||
{
|
||||
var uniformArgs = new ArgsUniform<Configuration>(PrintHelp, args);
|
||||
Config = uniformArgs.Parse(true);
|
||||
|
||||
await client.LoginAsync(TokenType.Bot, token);
|
||||
await client.StartAsync();
|
||||
await Task.Delay(-1);
|
||||
return new Program().MainAsync();
|
||||
}
|
||||
|
||||
public async Task MainAsync()
|
||||
{
|
||||
Console.WriteLine("Starting Codex Discord Bot...");
|
||||
client = new DiscordSocketClient();
|
||||
|
||||
client.Log += Log;
|
||||
|
||||
// You can assign your bot token to a string, and pass that in to connect.
|
||||
// This is, however, insecure, particularly if you plan to have your code hosted in a public repository.
|
||||
var token = "token";
|
||||
|
||||
await client.LoginAsync(TokenType.Bot, token);
|
||||
await client.StartAsync();
|
||||
Console.WriteLine("Running...");
|
||||
await Task.Delay(-1);
|
||||
}
|
||||
|
||||
private static void PrintHelp()
|
||||
{
|
||||
Console.WriteLine("BiblioTech - Codex Discord Bot");
|
||||
}
|
||||
|
||||
private Task Log(LogMessage msg)
|
||||
{
|
||||
Console.WriteLine(msg.ToString());
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
private Task Log(LogMessage msg)
|
||||
{
|
||||
Console.WriteLine(msg.ToString());
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
docker build -f docker/Dockerfile -t thatbenbierens/codex-discordbot:initial ../..
|
||||
docker push thatbenbierens/codex-discordbot:initial
|
|
@ -0,0 +1,6 @@
|
|||
FROM mcr.microsoft.com/dotnet/sdk:7.0
|
||||
|
||||
WORKDIR app
|
||||
COPY ./Tools/BiblioTech ./Tools/BiblioTech
|
||||
COPY ./Framework/ArgsUniform ./Framework/ArgsUniform
|
||||
CMD ["dotnet", "run", "--project", "Tools/BiblioTech"]
|
|
@ -0,0 +1,6 @@
|
|||
services:
|
||||
bibliotech-discordbot:
|
||||
image: thatbenbierens/codex-discordbot:initial
|
||||
environment:
|
||||
- TOKEN=tokenplz
|
||||
- DEPLOYS=deploypath
|
Loading…
Reference in New Issue