Added .doas command which executes the command as if you were the target user

This commit is contained in:
Kwoth
2022-11-19 22:36:18 +01:00
parent 8a6edc17e4
commit f24692e79b
5 changed files with 169 additions and 4 deletions

View File

@@ -35,6 +35,26 @@ public partial class Administration
_medusaLoader = medusaLoader;
}
[Cmd]
[OwnerOnly]
public async Task DoAs(IUser user, [Leftover] string message)
{
if (ctx.User is not IGuildUser { GuildPermissions.Administrator: true })
return;
if (ctx.Guild is SocketGuild sg && ctx.Channel is ISocketMessageChannel ch
&& ctx.Message is SocketUserMessage msg)
{
var fakeMessage = new DoAsUserMessage(msg, user, message);
await _cmdHandler.TryRunCommand(sg, ch, fakeMessage);
}
else
{
await ReplyErrorLocalizedAsync(strs.error_occured);
}
}
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)]