diff --git a/Moonlight/App/Services/DiscordBot/Commands/ServerListCommand.cs b/Moonlight/App/Services/DiscordBot/Commands/ServerListCommand.cs index 5fe5a9dc..68e7fada 100644 --- a/Moonlight/App/Services/DiscordBot/Commands/ServerListCommand.cs +++ b/Moonlight/App/Services/DiscordBot/Commands/ServerListCommand.cs @@ -1,10 +1,9 @@ using Discord; using Discord.WebSocket; +using Logging.Net; using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; using Moonlight.App.Repositories; using Moonlight.App.Repositories.Servers; -using UserStatus = Moonlight.App.Models.Misc.UserStatus; namespace Moonlight.App.Services.DiscordBot.Commands; @@ -23,8 +22,9 @@ public class ServerListCommand : BaseModule if (command.User.IsBot) return; if (command.CommandName != "servers") return; - var usersRepo = Scope.ServiceProvider.GetRequiredService>(); + var usersRepo = Scope.ServiceProvider.GetRequiredService(); var user = usersRepo.Get().FirstOrDefault(x => x.DiscordId == command.User.Id); + //var user = usersRepo.Get().FirstOrDefault(x => x.Id == 1); if (user == null) { @@ -42,13 +42,10 @@ public class ServerListCommand : BaseModule foreach (var server in servers.Take(25)) { - if (!server.Suspended && server.Owner.DiscordId == command.User.Id && user.Status is not (UserStatus.Banned or UserStatus.Disabled)) - { - selectOptions.Add(new SelectMenuOptionBuilder() - .WithLabel($"{server.Id} - {server.Name}") - .WithEmote(Emote.Parse("<:server3:968614410228736070>")) - .WithValue(server.Id.ToString())); - } + selectOptions.Add(new SelectMenuOptionBuilder() + .WithLabel($"{server.Id} - {server.Name}") + .WithEmote(Emote.Parse("<:server3:968614410228736070>")) + .WithValue(server.Id.ToString())); } components = new ComponentBuilder(); diff --git a/Moonlight/App/Services/DiscordBot/DiscordBotService.cs b/Moonlight/App/Services/DiscordBot/DiscordBotService.cs index 696fc335..5a64d70a 100644 --- a/Moonlight/App/Services/DiscordBot/DiscordBotService.cs +++ b/Moonlight/App/Services/DiscordBot/DiscordBotService.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using Discord; +using Discord.Commands; using Discord.WebSocket; using Logging.Net; using Moonlight.App.Services.DiscordBot.Commands; diff --git a/Moonlight/App/Services/DiscordBot/Modules/ServerListComponentHandlerModule.cs b/Moonlight/App/Services/DiscordBot/Modules/ServerListComponentHandlerModule.cs index ee645f93..24bcb79d 100644 --- a/Moonlight/App/Services/DiscordBot/Modules/ServerListComponentHandlerModule.cs +++ b/Moonlight/App/Services/DiscordBot/Modules/ServerListComponentHandlerModule.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore; using Moonlight.App.ApiClients.Wings; using Moonlight.App.Repositories; using Moonlight.App.Repositories.Servers; -using UserStatus = Moonlight.App.Models.Misc.UserStatus; namespace Moonlight.App.Services.DiscordBot.Modules; @@ -31,8 +30,7 @@ public class ServerListComponentHandlerModule : BaseModule var dcs = Scope.ServiceProvider.GetRequiredService(); var costomId = component.Data.CustomId.Split("."); EmbedBuilder embed = dcs.EmbedBuilderModule.StandardEmbed("Something went terribly wrong! \n Mission failed please try again later.", Color.Red, component.User); - ComponentBuilder components = new(); - + if (costomId.Length < 3) return; if(costomId[0] is not "Sm") return; @@ -49,25 +47,11 @@ public class ServerListComponentHandlerModule : BaseModule await ErrorEmbedSnippet(component); return; } - - var usersRepo = Scope.ServiceProvider.GetRequiredService>(); - var user = usersRepo.Get().FirstOrDefault(x => x.DiscordId == component.User.Id); - - if (user == null) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry ;( \n Please first create and/or link a Account to Discord! \n Press the Button to register/log in.", Color.Red, component.User); - components.WithButton("Click Here", style: ButtonStyle.Link, url: ConfigService.GetSection("Moonlight").GetValue("AppUrl")); - - await component.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true); - await component.DeleteOriginalResponseAsync(); - return; - } - - if (server.Suspended || user.Status is not (UserStatus.Banned or UserStatus.Disabled) || server.Owner.DiscordId != component.User.Id) + + if (server.Owner.DiscordId != component.User.Id) { embed = dcs.EmbedBuilderModule.StandardEmbed("Is this your Server? I don't think so. \n Yes i did think of that.", Color.Red, component.User); await component.RespondAsync(embed: embed.Build(), ephemeral: true); - await component.DeleteOriginalResponseAsync(); return; } @@ -151,7 +135,7 @@ public class ServerListComponentHandlerModule : BaseModule case "Stop": - if (serverDetails.State is not ("starting" or "stopping" or "running")) + if (serverDetails.State is not ("starting" or "stopping")) { embed = dcs.EmbedBuilderModule.StandardEmbed("Server is in a Invalid State \n please try again later.", Color.Red, component.User); await component.RespondAsync(embed: embed.Build(), ephemeral: true);