Fix error on DMing with no permission
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Myriad.Extensions;
|
||||
using Myriad.Rest.Exceptions;
|
||||
using Myriad.Rest.Types;
|
||||
using Myriad.Rest.Types.Requests;
|
||||
@@ -143,7 +144,7 @@ namespace PluralKit.Bot
|
||||
|
||||
try
|
||||
{
|
||||
var dm = await ctx.Rest.CreateDm(ctx.Author.Id);
|
||||
var dm = await ctx.Cache.GetOrCreateDmChannel(ctx.Rest, ctx.Author.Id);
|
||||
|
||||
var msg = await ctx.Rest.CreateMessage(dm.Id,
|
||||
new MessageRequest {Content = $"{Emojis.Success} Here you go!"},
|
||||
@@ -154,7 +155,7 @@ namespace PluralKit.Bot
|
||||
if (ctx.Channel.Type != Channel.ChannelType.Dm)
|
||||
await ctx.Reply($"{Emojis.Success} Check your DMs!");
|
||||
}
|
||||
catch (UnauthorizedException)
|
||||
catch (ForbiddenException)
|
||||
{
|
||||
// If user has DMs closed, tell 'em to open them
|
||||
await ctx.Reply(
|
||||
|
@@ -40,7 +40,7 @@ namespace PluralKit.Bot
|
||||
if (ctx.Channel.Type != Channel.ChannelType.Dm)
|
||||
await ctx.Reply($"{Emojis.Success} Check your DMs!");
|
||||
}
|
||||
catch (UnauthorizedException)
|
||||
catch (ForbiddenException)
|
||||
{
|
||||
// Can't check for permission errors beforehand, so have to handle here :/
|
||||
if (ctx.Channel.Type != Channel.ChannelType.Dm)
|
||||
@@ -84,7 +84,7 @@ namespace PluralKit.Bot
|
||||
if (ctx.Channel.Type != Channel.ChannelType.Dm)
|
||||
await ctx.Reply($"{Emojis.Success} Check your DMs!");
|
||||
}
|
||||
catch (UnauthorizedException)
|
||||
catch (ForbiddenException)
|
||||
{
|
||||
// Can't check for permission errors beforehand, so have to handle here :/
|
||||
if (ctx.Channel.Type != Channel.ChannelType.Dm)
|
||||
|
Reference in New Issue
Block a user