Skip to content

Commit

Permalink
fix !help outside server showing extra commands it shouldnt
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisa committed Jan 13, 2025
1 parent ef70e65 commit db7b569
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Commands/GlobalCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,20 @@ private async Task<IEnumerable<ContextCheckAttribute>> CheckPermissionsAsync(Com

foreach (var check in contextChecks)
{
if (check is HomeServerAttribute homeServerAttribute)
// if command requiring homes erver is used outside, fail the check
if (check is HomeServerAttribute homeServerAttribute
&& (ctx.Channel.IsPrivate || ctx.Guild is null || ctx.Guild.Id != Program.cfgjson.ServerID)
)
{
if (ctx.Channel.IsPrivate || ctx.Guild is null || ctx.Guild.Id != Program.cfgjson.ServerID)
{
failedChecks.Add(homeServerAttribute);
}
failedChecks.Add(homeServerAttribute);
}

if (check is RequireHomeserverPermAttribute requireHomeserverPermAttribute)
{
// Fail if guild member is null but this cmd does not work outside of the home server
if (member is null && !requireHomeserverPermAttribute.WorkOutside)
// Fail if guild is wrong but this command does not work outside of the home server
if (
(ctx.Channel.IsPrivate || ctx.Guild is null || ctx.Guild.Id != Program.cfgjson.ServerID)
&& !requireHomeserverPermAttribute.WorkOutside)
{
failedChecks.Add(requireHomeserverPermAttribute);
}
Expand Down

0 comments on commit db7b569

Please sign in to comment.