mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
fix(bot): fix utility admin command
This commit is contained in:
parent
8bca02032f
commit
ebf8a40369
1 changed files with 8 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ using Myriad.Cache;
|
|||
using Myriad.Rest;
|
||||
using Myriad.Types;
|
||||
using Myriad.Rest.Types.Requests;
|
||||
using Myriad.Rest.Exceptions;
|
||||
|
||||
using PluralKit.Core;
|
||||
|
||||
|
|
@ -20,12 +21,14 @@ 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)
|
||||
public Admin(BotConfig botConfig, DiscordApiClient rest, IDiscordCache cache, PrivateChannelService dmCache)
|
||||
{
|
||||
_botConfig = botConfig;
|
||||
_rest = rest;
|
||||
_cache = cache;
|
||||
_dmCache = dmCache;
|
||||
}
|
||||
|
||||
private Task<(ulong Id, User? User)[]> GetUsers(IEnumerable<ulong> ids)
|
||||
|
|
@ -513,15 +516,16 @@ public class Admin
|
|||
|
||||
try
|
||||
{
|
||||
var dm = await _rest.CreateDm(account.Id);
|
||||
var msg = await ctx.Rest.CreateMessage(dm.Id,
|
||||
var dm = await _dmCache.GetOrCreateDmChannel(account.Id);
|
||||
var msg = await ctx.Rest.CreateMessage(dm,
|
||||
new MessageRequest { Content = messageContent }
|
||||
);
|
||||
}
|
||||
catch (Exception)
|
||||
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