Change "channel not found" error messages to be more ambiguous; also, put them in Errors instead of inline
This commit is contained in:
parent
4006d353f2
commit
d9c644ec0e
@ -25,9 +25,11 @@ namespace PluralKit.Bot
|
|||||||
ctx.CheckGuildContext().CheckAuthorPermission(Permissions.ManageGuild, "Manage Server");
|
ctx.CheckGuildContext().CheckAuthorPermission(Permissions.ManageGuild, "Manage Server");
|
||||||
|
|
||||||
DiscordChannel channel = null;
|
DiscordChannel channel = null;
|
||||||
if (ctx.HasNext())
|
if (!ctx.HasNext())
|
||||||
channel = await ctx.MatchChannel() ?? throw new PKSyntaxError("You must pass a #channel to set.");
|
throw new PKSyntaxError("You must pass a #channel to set.");
|
||||||
if (channel != null && channel.GuildId != ctx.Guild.Id) throw new PKError("That channel is not in this server!");
|
var channelString = ctx.PeekArgument();
|
||||||
|
channel = await ctx.MatchChannel();
|
||||||
|
if (channel == null || channel.GuildId != ctx.Guild.Id) throw Errors.ChannelNotFound(channelString);
|
||||||
|
|
||||||
var patch = new GuildPatch {LogChannel = channel?.Id};
|
var patch = new GuildPatch {LogChannel = channel?.Id};
|
||||||
await _db.Execute(conn => conn.UpsertGuild(ctx.Guild.Id, patch));
|
await _db.Execute(conn => conn.UpsertGuild(ctx.Guild.Id, patch));
|
||||||
@ -48,8 +50,9 @@ namespace PluralKit.Bot
|
|||||||
else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels.");
|
else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels.");
|
||||||
else while (ctx.HasNext())
|
else while (ctx.HasNext())
|
||||||
{
|
{
|
||||||
var channel = await ctx.MatchChannel() ?? throw new PKSyntaxError($"Channel \"{ctx.PopArgument()}\" not found.");
|
var channelString = ctx.PeekArgument();
|
||||||
if (channel.GuildId != ctx.Guild.Id) throw new PKError($"Channel {ctx.Guild.Id} is not in this server.");
|
var channel = await ctx.MatchChannel();
|
||||||
|
if (channel == null || channel.GuildId != ctx.Guild.Id) throw Errors.ChannelNotFound(channelString);
|
||||||
affectedChannels.Add(channel);
|
affectedChannels.Add(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +130,9 @@ namespace PluralKit.Bot
|
|||||||
else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels.");
|
else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels.");
|
||||||
else while (ctx.HasNext())
|
else while (ctx.HasNext())
|
||||||
{
|
{
|
||||||
var channel = await ctx.MatchChannel() ?? throw new PKSyntaxError($"Channel \"{ctx.PopArgument()}\" not found.");
|
var channelString = ctx.PeekArgument();
|
||||||
if (channel.GuildId != ctx.Guild.Id) throw new PKError($"Channel {ctx.Guild.Id} is not in this server.");
|
var channel = await ctx.MatchChannel();
|
||||||
|
if (channel == null || channel.GuildId != ctx.Guild.Id) throw Errors.ChannelNotFound(channelString);
|
||||||
affectedChannels.Add(channel);
|
affectedChannels.Add(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,5 +114,6 @@ namespace PluralKit.Bot {
|
|||||||
|
|
||||||
public static PKError AttachmentTooLarge => new PKError("PluralKit cannot proxy attachments over 8 megabytes (as webhooks aren't considered as having Discord Nitro) :(");
|
public static PKError AttachmentTooLarge => new PKError("PluralKit cannot proxy attachments over 8 megabytes (as webhooks aren't considered as having Discord Nitro) :(");
|
||||||
public static PKError LookupNotAllowed => new PKError("You do not have permission to access this information.");
|
public static PKError LookupNotAllowed => new PKError("You do not have permission to access this information.");
|
||||||
|
public static PKError ChannelNotFound(string channelString) => new PKError($"Channel \"{channelString}\" not found or is not in this server.");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user