mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-12 16:50:10 +00:00
Compare commits
No commits in common. "ebf8a403695f10a947430aa59e90fe99d708c2bd" and "4293f26b8a69ac3b0a56d56531fb8e6cd3cabd7e" have entirely different histories.
ebf8a40369
...
4293f26b8a
2 changed files with 1 additions and 37 deletions
|
|
@ -181,8 +181,6 @@ public partial class CommandTree
|
|||
await ctx.Execute<Admin>(Admin, a => a.SystemRecover(ctx));
|
||||
else if (ctx.Match("sd", "systemdelete"))
|
||||
await ctx.Execute<Admin>(Admin, a => a.SystemDelete(ctx));
|
||||
else if (ctx.Match("sendmsg", "sendmessage"))
|
||||
await ctx.Execute<Admin>(Admin, a => a.SendAdminMessage(ctx));
|
||||
else if (ctx.Match("al", "abuselog"))
|
||||
await HandleAdminAbuseLogCommand(ctx);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ using Myriad.Extensions;
|
|||
using Myriad.Cache;
|
||||
using Myriad.Rest;
|
||||
using Myriad.Types;
|
||||
using Myriad.Rest.Types.Requests;
|
||||
using Myriad.Rest.Exceptions;
|
||||
|
||||
using PluralKit.Core;
|
||||
|
||||
|
|
@ -21,14 +19,12 @@ public class Admin
|
|||
private readonly BotConfig _botConfig;
|
||||
private readonly DiscordApiClient _rest;
|
||||
private readonly IDiscordCache _cache;
|
||||
private readonly PrivateChannelService _dmCache;
|
||||
|
||||
public Admin(BotConfig botConfig, DiscordApiClient rest, IDiscordCache cache, PrivateChannelService dmCache)
|
||||
public Admin(BotConfig botConfig, DiscordApiClient rest, IDiscordCache cache)
|
||||
{
|
||||
_botConfig = botConfig;
|
||||
_rest = rest;
|
||||
_cache = cache;
|
||||
_dmCache = dmCache;
|
||||
}
|
||||
|
||||
private Task<(ulong Id, User? User)[]> GetUsers(IEnumerable<ulong> ids)
|
||||
|
|
@ -500,34 +496,4 @@ public class Admin
|
|||
await ctx.Repository.DeleteAbuseLog(abuseLog.Id);
|
||||
await ctx.Reply($"{Emojis.Success} Successfully deleted abuse log entry.");
|
||||
}
|
||||
|
||||
public async Task SendAdminMessage(Context ctx)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
var account = await ctx.MatchUser();
|
||||
if (account == null)
|
||||
throw new PKError("You must pass an account to send an admin message to (either ID or @mention).");
|
||||
if (!ctx.HasNext())
|
||||
throw new PKError("You must provide a message to send.");
|
||||
|
||||
var content = ctx.RemainderOrNull(false).NormalizeLineEndSpacing();
|
||||
var messageContent = $"## [Admin Message]\n\n{content}\n\nWe cannot read replies sent to this DM. If you wish to contact the staff team, please join the support server (<https://discord.gg/PczBt78>) or send us an email at <legal@pluralkit.me>.";
|
||||
|
||||
try
|
||||
{
|
||||
var dm = await _dmCache.GetOrCreateDmChannel(account.Id);
|
||||
var msg = await ctx.Rest.CreateMessage(dm,
|
||||
new MessageRequest { Content = messageContent }
|
||||
);
|
||||
}
|
||||
catch (ForbiddenException)
|
||||
{
|
||||
await ctx.Reply(
|
||||
$"{Emojis.Error} Error while sending DM.");
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.Reply($"{Emojis.Success} Successfully sent message.");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue