Skip to content

Commit

Permalink
Help me. This really sucks.
Browse files Browse the repository at this point in the history
  • Loading branch information
sylveonnotdeko committed Apr 7, 2024
1 parent 6932e1b commit ee43cfb
Show file tree
Hide file tree
Showing 60 changed files with 3,748 additions and 1,375 deletions.
5 changes: 2 additions & 3 deletions src/Mewdeko/Common/Yml/MultilineScalarFlowStyleEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ public override void Emit(ScalarEventInfo eventInfo, IEmitter emitter)
if (!string.IsNullOrEmpty(value))
{
// Determine if the string value contains any multi-line characters.
var isMultiLine = value.IndexOfAny(new[]
{
var isMultiLine = value.IndexOfAny([
'\r', '\n', '\x85', '\x2028', '\x2029'
}) >= 0;
]) >= 0;
if (isMultiLine)
{
// Emit the scalar event in literal style for multi-line values.
Expand Down
6 changes: 3 additions & 3 deletions src/Mewdeko/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@ public static string[] GetCtNames(this IApplicationCommand command)
x.Type is ApplicationCommandOptionType.SubCommand or ApplicationCommandOptionType.SubCommandGroup);

if (!sgs.Any())
return new[]
{
return
[
baseName
};
];

var ctNames = new List<string>();
foreach (var sg in sgs)
Expand Down
42 changes: 17 additions & 25 deletions src/Mewdeko/Modules/Chat Triggers/Services/ChatTriggersService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public async Task<bool> ImportCrsAsync(IGuildUser user, string input)
await using var uow = db.GetDbContext();

// Initialize a list to store CTModel objects representing chat triggers
List<CTModel> triggers = new List<CTModel>();
List<CTModel> triggers = [];
foreach (var (trigger, value) in data)
{
// Convert exported triggers to CTModel objects and add them to the list
Expand All @@ -607,7 +607,7 @@ public async Task<bool> ImportCrsAsync(IGuildUser user, string input)
}

// Check if the user has permission to manage all roles involved in the import
List<ulong> roles = new List<ulong>();
List<ulong> roles = [];
triggers.ForEach(x => roles.AddRange(x.GetGrantedRoles()));
triggers.ForEach(x => roles.AddRange(x.GetRemovedRoles()));

Expand Down Expand Up @@ -1945,13 +1945,11 @@ public static bool IsValidName(CtApplicationCommandType type, string name)
// Check if the trigger name is valid
if (!IsValidName(trigger.ApplicationCommandType, trigger.RealName))
{
errors.Add(new ChatTriggersInteractionError("invalid_name", new[]
{
errors.Add(new ChatTriggersInteractionError("invalid_name", [
trigger.Id
}, new[]
{
], [
trigger.RealName
}));
]));
}

// Check for duplicate trigger names and subcommand matching parent triggers
Expand All @@ -1961,38 +1959,32 @@ public static bool IsValidName(CtApplicationCommandType type, string name)

if (trigger.RealName == newTrigger.RealName)
{
errors.Add(new ChatTriggersInteractionError("duplicate", new[]
{
errors.Add(new ChatTriggersInteractionError("duplicate", [
trigger.Id, newTrigger.Id
},
new[]
{
],
[
trigger.RealName, newTrigger.RealName
}));
]));
}

switch (triggerDepth)
{
case 1 when newTriggerDepth == 2 && newTrigger.RealName.Split(' ')[0] == trigger.RealName:
errors.Add(new ChatTriggersInteractionError("subcommand_match_parent", new[]
{
errors.Add(new ChatTriggersInteractionError("subcommand_match_parent", [
trigger.Id, newTrigger.Id
},
new[]
{
],
[
trigger.RealName, newTrigger.RealName
}));
]));
break;
case 2 when newTriggerDepth == 3 &&
string.Join(' ', newTrigger.RealName.Split(' ').Take(2)) == trigger.RealName:
errors.Add(new ChatTriggersInteractionError("subcommand_match_parent", new[]
{
errors.Add(new ChatTriggersInteractionError("subcommand_match_parent", [
trigger.Id, newTrigger.Id
},
new[]
{
],
[
trigger.RealName, newTrigger.RealName
}));
]));
break;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Mewdeko/Modules/Currency/Currency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ await ctx.Channel.SendErrorAsync(
}

string[] segments =
{
[
"-$10", "-10%", "+$10", "+30%", "+$30", "-5%"
};
];
int[] weights =
{
[
2, 2, 1, 1, 1, 2
};
];
var rand = new Random();
var winningSegment = GenerateWeightedRandomSegment(segments.Length, weights, rand);

Expand Down
13 changes: 7 additions & 6 deletions src/Mewdeko/Modules/Games/Common/GamesConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,34 @@ public sealed class GamesConfig
/// List of responses for the .8ball command. A random one will be selected every time.
/// </summary>
[Comment("List of responses for the .8ball command. A random one will be selected every time")]
public List<string> EightBallResponses { get; set; } = new()
{
public List<string> EightBallResponses { get; set; } =
[
"Most definitely yes.",
"For sure.",
"Totally!",
"Of course!",
// Add more responses here
"Definitely no.",
"NO - It may cause disease contraction!"
};
];

/// <summary>
/// List of animals which will be used for the animal race game (.race).
/// </summary>
[Comment("List of animals which will be used for the animal race game (.race)")]
public List<RaceAnimal> RaceAnimals { get; set; } = new()
{
public List<RaceAnimal> RaceAnimals { get; set; } =
[
new RaceAnimal
{
Icon = "🐼", Name = "Panda"
},
// Add more race animals here

new RaceAnimal
{
Icon = "🦄", Name = "Unicorn"
}
};
];
}

/// <summary>
Expand Down
Loading

0 comments on commit ee43cfb

Please sign in to comment.