Skip to content

Commit

Permalink
Merge pull request #450 from zaanposni/release/v2.3.0
Browse files Browse the repository at this point in the history
Release/v2.3.0
  • Loading branch information
zaanposni authored Nov 23, 2021
2 parents e7d11c4 + f09a61f commit 2428bac
Show file tree
Hide file tree
Showing 34 changed files with 1,036 additions and 35 deletions.
39 changes: 39 additions & 0 deletions backend/masz/Commands/AvatarCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;

namespace masz.Commands
{

public class AvatarCommand : BaseCommand<AvatarCommand>
{
public AvatarCommand(IServiceProvider serviceProvider) : base(serviceProvider) { }

[SlashCommand("avatar", "Get the high resolution avatar of a user.")]
public async Task Avatar(InteractionContext ctx, [Option("user", "User to get the avatar from")] DiscordUser user)
{
DiscordMember member = null;
try
{
member = await ctx.Guild.GetMemberAsync(user.Id);
} catch (Exception) { }

DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
embed.WithTitle("Avatar");
embed.WithFooter($"UserId: {user.Id}");
if (member != null && member.GuildAvatarHash != user.AvatarHash)
{
embed.WithUrl(member.GuildAvatarUrl);
embed.WithImageUrl(member.GuildAvatarUrl);
} else
{
embed.WithUrl(user.AvatarUrl);
embed.WithImageUrl(user.AvatarUrl);
}

await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(embed.Build()).AsEphemeral(true));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using masz.Dtos.Enum;
using masz.Enums;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace masz.Controllers
{
[ApiController]
[Route("api/v1/enums/")]
public class AutoModerationChannelNotificationBehaviorEnumController : SimpleController
{
private readonly ILogger<AutoModerationChannelNotificationBehaviorEnumController> _logger;

public AutoModerationChannelNotificationBehaviorEnumController(ILogger<AutoModerationChannelNotificationBehaviorEnumController> logger, IServiceProvider serviceProvider) : base(serviceProvider)
{
_logger = logger;
}

[HttpGet("automodchannelbehavior")]
public IActionResult ChannelNotificationBehavior([FromQuery] Language? language = null) {
_translator.SetContext(language);
return Ok(new List<EnumDto>()
{
EnumDto.Create((int) AutoModerationChannelNotificationBehavior.SendNotification, _translator.T().Enum(AutoModerationChannelNotificationBehavior.SendNotification)),
EnumDto.Create((int) AutoModerationChannelNotificationBehavior.SendNotificationAndDelete, _translator.T().Enum(AutoModerationChannelNotificationBehavior.SendNotificationAndDelete)),
EnumDto.Create((int) AutoModerationChannelNotificationBehavior.NoNotification, _translator.T().Enum(AutoModerationChannelNotificationBehavior.NoNotification))
});
}
}
}
24 changes: 23 additions & 1 deletion backend/masz/Controllers/api/v1/ModCaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async Task<IActionResult> LockComments([FromRoute] ulong guildId, [FromRo
await RequirePermission(guildId, caseId, APIActionPermission.Edit);

Identity currentIdentity = await GetIdentity();
ModCase modCase = await ModCaseRepository.CreateDefault(_serviceProvider, currentIdentity).LockCaseComments(guildId, caseId, currentIdentity.GetCurrentUser());
ModCase modCase = await ModCaseRepository.CreateDefault(_serviceProvider, currentIdentity).LockCaseComments(guildId, caseId);

return Ok(modCase);
}
Expand All @@ -173,5 +173,27 @@ public async Task<IActionResult> UnlockComments([FromRoute] ulong guildId, [From

return Ok(modCase);
}

[HttpPost("{caseId}/active")]
public async Task<IActionResult> ActivateCase([FromRoute] ulong guildId, [FromRoute] int caseId)
{
await RequirePermission(guildId, caseId, APIActionPermission.Edit);

Identity currentIdentity = await GetIdentity();
ModCase modCase = await ModCaseRepository.CreateDefault(_serviceProvider, currentIdentity).ActivateModCase(guildId, caseId);

return Ok(modCase);
}

[HttpDelete("{caseId}/active")]
public async Task<IActionResult> DeactivateCase([FromRoute] ulong guildId, [FromRoute] int caseId)
{
await RequirePermission(guildId, caseId, APIActionPermission.Edit);

Identity currentIdentity = await GetIdentity();
ModCase modCase = await ModCaseRepository.CreateDefault(_serviceProvider, currentIdentity).DeactivateModCase(guildId, caseId);

return Ok(modCase);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public class AutoModerationConfigForPutDto
public string CustomWordFilter { get; set; }
public bool SendDmNotification { get; set; }
public bool SendPublicNotification { get; set; }
public AutoModerationChannelNotificationBehavior ChannelNotificationBehavior { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace masz.Enums
{
public enum AutoModerationChannelNotificationBehavior
{
SendNotification,
SendNotificationAndDelete,
NoNotification
}
}
Loading

0 comments on commit 2428bac

Please sign in to comment.