Codacy refactoring
This commit is contained in:
parent
ea1516e5db
commit
4bac506bfc
4 changed files with 29 additions and 39 deletions
|
@ -30,10 +30,14 @@ public class CreateSelectionBoxPanelCommand : ApplicationCommandModule
|
|||
{
|
||||
List<Database.Category> verifiedCategories = await Utilities.GetVerifiedChannels();
|
||||
|
||||
if (verifiedCategories.Count == 0) return new List<DiscordSelectComponent>();
|
||||
if (verifiedCategories.Count == 0)
|
||||
{
|
||||
return new List<DiscordSelectComponent>();
|
||||
}
|
||||
|
||||
verifiedCategories = verifiedCategories.OrderBy(x => x.name).ToList();
|
||||
List<DiscordSelectComponent> selectionComponents = new List<DiscordSelectComponent>();
|
||||
|
||||
int selectionOptions = 0;
|
||||
for (int selectionBoxes = 0; selectionBoxes < 5 && selectionOptions < verifiedCategories.Count; selectionBoxes++)
|
||||
{
|
||||
|
@ -51,9 +55,15 @@ public class CreateSelectionBoxPanelCommand : ApplicationCommandModule
|
|||
|
||||
public static async Task OnSelectionMenuUsed(DiscordInteraction interaction)
|
||||
{
|
||||
if (interaction.Data.Values == null || interaction.Data.Values.Length <= 0) return;
|
||||
if (interaction.Data.Values == null || interaction.Data.Values.Length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ulong.TryParse(interaction.Data.Values[0], out ulong categoryID) || categoryID == 0) return;
|
||||
if (!ulong.TryParse(interaction.Data.Values[0], out ulong categoryID) || categoryID == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource, new DiscordInteractionResponseBuilder().AsEphemeral());
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public class NewCommand : ApplicationCommandModule
|
|||
public static async Task CreateButtons(InteractionContext command, List<Database.Category> verifiedCategories)
|
||||
{
|
||||
DiscordInteractionResponseBuilder builder = new DiscordInteractionResponseBuilder().WithContent(" ");
|
||||
|
||||
int nrOfButtons = 0;
|
||||
for (int nrOfButtonRows = 0; nrOfButtonRows < 5 && nrOfButtons < verifiedCategories.Count; nrOfButtonRows++)
|
||||
{
|
||||
|
@ -82,6 +83,7 @@ public class NewCommand : ApplicationCommandModule
|
|||
{
|
||||
verifiedCategories = verifiedCategories.OrderBy(x => x.name).ToList();
|
||||
List<DiscordSelectComponent> selectionComponents = new List<DiscordSelectComponent>();
|
||||
|
||||
int selectionOptions = 0;
|
||||
for (int selectionBoxes = 0; selectionBoxes < 5 && selectionOptions < verifiedCategories.Count; selectionBoxes++)
|
||||
{
|
||||
|
@ -106,7 +108,10 @@ public class NewCommand : ApplicationCommandModule
|
|||
stringID = interaction.Data.CustomId.Replace("supportchild_newcommandbutton ", "");
|
||||
break;
|
||||
case ComponentType.StringSelect:
|
||||
if (interaction.Data.Values == null || interaction.Data.Values.Length <= 0) return;
|
||||
if (interaction.Data.Values == null || interaction.Data.Values.Length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stringID = interaction.Data.Values[0];
|
||||
break;
|
||||
|
||||
|
@ -116,7 +121,10 @@ public class NewCommand : ApplicationCommandModule
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ulong.TryParse(stringID, out ulong categoryID) || categoryID == 0) return;
|
||||
if (!ulong.TryParse(stringID, out ulong categoryID) || categoryID == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate, new DiscordInteractionResponseBuilder().AsEphemeral());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue