Skip to content

Commit

Permalink
Merge pull request #7 from eclipserporg/feature/fix_deploy
Browse files Browse the repository at this point in the history
Fix deployment issues
  • Loading branch information
pauliusdotpro authored Oct 28, 2023
2 parents c629475 + c816b74 commit d88f7dd
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "7.0.13",
"commands": [
"dotnet-ef"
]
}
}
}
3 changes: 3 additions & 0 deletions Apis/IServerDiscordApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public interface IServerDiscordApi
[Post("/save")]
Task<bool> PostSave();

[Get("/ping")]
Task<bool> GetPing();

[Post("/kick")]
Task<bool> PostKick(string channel, ulong senderId, string senderName, ulong targetId, string targetName, string reason);

Expand Down
30 changes: 28 additions & 2 deletions Commands/GeneralCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Serilog;

namespace app.Commands;

public class GeneralCommands : BaseCommandModule
Expand All @@ -21,17 +23,35 @@ public async Task HelpVerifyCommand(CommandContext ctx, DiscordMember targetMemb
{
if (ctx.Channel != _discordService.HelpVerifyChannel)
return;
Log.Information("HelpVerifyCommand");

await ctx.RespondAsync(
string.Format("Hello, <@{0}>! Check out the <#{1}> channel for detailed steps on how to join our roleplay server and on how to obtain access to our member-only channels.",
ctx.User.Id, _discordService.VerificationChannel.Id));
}

[Command("pingserver")]
public async Task PingServerCommand(CommandContext ctx)
{
if (ctx.Channel != _discordService.CommandsChannel)
return;

Log.Information("PingServerCommand");

var response = await _serverDiscordApi.GetPing();

if(response)
{
Log.Information("PingServerCommand: Success");
}
}

[Command("remove-read-only")]
public async Task RemoveReadOnlyCommand(CommandContext ctx, DiscordMember targetMember)
{
if (ctx.Channel != _discordService.CommandsChannel)
return;
Log.Information("RemoveReadOnlyCommand");

var senderMember = ctx.Member;

Expand Down Expand Up @@ -66,6 +86,7 @@ public async Task ListCommand(CommandContext ctx)
{
if (ctx.Channel != _discordService.CommandsChannel)
return;
Log.Information("ListCommand");

var message = "```\n";
message += "!ban;user_id;reason\n";
Expand All @@ -87,6 +108,7 @@ public async Task ReadOnlyCommand(CommandContext ctx, DiscordMember targetMember
{
if (ctx.Channel != _discordService.CommandsChannel)
return;
Log.Information("ReadOnlyCommand");

var senderMember = ctx.Member;

Expand Down Expand Up @@ -119,6 +141,7 @@ public async Task AppsCommand(CommandContext ctx)
{
if (ctx.Channel != _discordService.CommandsChannel)
return;
Log.Information("AppsCommand");

var waitingIssuers = await _serverDiscordApi.GetApps();
await ctx.RespondAsync(waitingIssuers);
Expand All @@ -127,6 +150,7 @@ public async Task AppsCommand(CommandContext ctx)
[Command("ann")]
public async Task AnnCommand(CommandContext ctx, string text)
{
Log.Information("AnnCommand");
if (ctx.Channel != _discordService.CommandsChannel)
return;

Expand All @@ -138,8 +162,8 @@ public async Task SaveCommand(CommandContext ctx)
{
if (ctx.Channel != _discordService.CommandsChannel)
return;

if(await _serverDiscordApi.PostSave())
Log.Information("SaveCommand");
if (await _serverDiscordApi.PostSave())
{
await ctx.RespondAsync("Saved to database!");
}
Expand All @@ -154,6 +178,7 @@ public async Task KickCommand(CommandContext ctx, DiscordMember targetMember, st
{
if (ctx.Channel != _discordService.CommandsChannel)
return;
Log.Information("KickCommand");

var senderMember = ctx.Member;

Expand All @@ -180,6 +205,7 @@ public async Task BanCommand(CommandContext ctx, DiscordMember targetMember, str
{
if (ctx.Channel != _discordService.CommandsChannel)
return;
Log.Information("BanCommand");

var senderMember = ctx.Member;

Expand Down
5 changes: 5 additions & 0 deletions Controllers/DiscordController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using app.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Serilog;

namespace app.Controllers
{
Expand All @@ -20,6 +21,7 @@ public DiscordController(DiscordService discordService)
[HttpGet(Name = "hasContentCreator")]
public async Task<bool> GetHasContentCreator(ulong id)
{
Log.Information("Get hasContentCreator");
var member = await _discordService.Guild.GetMemberAsync(id);

if(member == null)
Expand All @@ -31,6 +33,7 @@ public async Task<bool> GetHasContentCreator(ulong id)
[HttpGet(Name = "user")]
public async Task<DiscordUserDto?> GetUser(ulong id)
{
Log.Information("Get user");
var member = await _discordService.Guild.GetMemberAsync(id);

if (member == null)
Expand All @@ -48,6 +51,7 @@ public async Task<bool> GetHasContentCreator(ulong id)
[HttpPost(Name = "grantRole")]
public async Task PostGrantRole(ulong id, string role)
{
Log.Information("Post grantRole");
var member = await _discordService.Guild.GetMemberAsync(id);

if (member == null)
Expand All @@ -69,6 +73,7 @@ public async Task PostGrantRole(ulong id, string role)
[HttpPost(Name = "revokeRole")]
public async Task PostRevokeRole(ulong id, string role)
{
Log.Information("Post revokeRole");
var member = await _discordService.Guild.GetMemberAsync(id);

if (member == null)
Expand Down
2 changes: 2 additions & 0 deletions Controllers/FeedsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using app.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Serilog;

namespace app.Controllers
{
Expand All @@ -18,6 +19,7 @@ public FeedsController(DiscordService discordService)
[HttpPost(Name = "send")]
public async Task PostSend(string channel, string message)
{
Log.Information("Post send");
var discordChannel = channel switch
{
nameof (_discordService.HelpVerifyChannel) => _discordService.HelpVerifyChannel,
Expand Down
2 changes: 2 additions & 0 deletions Controllers/PresenceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using DSharpPlus.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Serilog;

namespace app.Controllers
{
Expand All @@ -20,6 +21,7 @@ public PresenceController(DiscordService discordService)
[HttpPost(Name = "players")]
public void PostPlayers(int playerCount)
{
Log.Information("Post players");
_discordService.Client.UpdateStatusAsync(new DiscordActivity($"with {playerCount} players!", ActivityType.Playing));
}
}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["app.csproj", "."]
RUN dotnet restore "./app.csproj"
Expand Down
13 changes: 13 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@
using app.Models;
using app.Middlewares;
using Microsoft.AspNetCore.Authentication;
using Serilog.Events;
using Serilog;
using Microsoft.AspNetCore.Hosting;

var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddEnvironmentVariables();
builder.WebHost.UseUrls("http://*:7031");


Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.CreateLogger();

var serverApiSettings = new ServerApiSettings();
builder.Configuration.GetSection(nameof(ServerApiSettings)).Bind(serverApiSettings);



builder.Services.Configure<DiscordSettings>(options => builder.Configuration.GetSection(nameof(DiscordSettings)).Bind(options));
builder.Services.Configure<ServerApiSettings>(options => builder.Configuration.GetSection(nameof(ServerApiSettings)).Bind(options));
builder.Services.Configure<Credentials>(options => builder.Configuration.GetSection(nameof(Credentials)).Bind(options));
Expand Down
1 change: 1 addition & 0 deletions app.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down

0 comments on commit d88f7dd

Please sign in to comment.