bot: add member deletion command
This commit is contained in:
parent
5fc91d895c
commit
72a2fadff8
@ -167,6 +167,18 @@ namespace PluralKit.Bot.Commands
|
||||
await Context.Channel.SendMessageAsync($"{Emojis.Success} Member proxy tags changed to `{ContextEntity.ProxyString}`. Try proxying now!");
|
||||
}
|
||||
|
||||
[Command("delete")]
|
||||
[Alias("remove", "erase", "yeet")]
|
||||
[Remarks("member <member> delete")]
|
||||
[MustPassOwnMember]
|
||||
public async Task MemberDelete()
|
||||
{
|
||||
await Context.Channel.SendMessageAsync($"{Emojis.Warn} Are you sure you want to delete \"{ContextEntity.Name}\"? If so, reply to this message with the member's ID (`{ContextEntity.Hid}`). __***This cannot be undone!***__");
|
||||
if (!await Context.ConfirmWithReply(ContextEntity.Hid)) throw Errors.MemberDeleteCancelled;
|
||||
await Members.Delete(ContextEntity);
|
||||
await Context.Channel.SendMessageAsync($"{Emojis.Success} Member deleted.");
|
||||
}
|
||||
|
||||
[Command]
|
||||
[Alias("view", "show", "info")]
|
||||
[Remarks("member")]
|
||||
|
@ -48,6 +48,12 @@ namespace PluralKit.Bot {
|
||||
(ctx.Client as BaseSocketClient).MessageReceived += Inner;
|
||||
return await (tcs.Task.TimeoutAfter(timeout));
|
||||
}
|
||||
|
||||
public static async Task<bool> ConfirmWithReply(this ICommandContext ctx, string expectedReply)
|
||||
{
|
||||
var msg = await ctx.AwaitMessage(ctx.Channel, ctx.User, timeout: TimeSpan.FromMinutes(1));
|
||||
return string.Equals(msg.Content, expectedReply, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public static async Task Paginate<T>(this ICommandContext ctx, ICollection<T> items, int itemsPerPage, string title, Action<EmbedBuilder, IEnumerable<T>> renderer) {
|
||||
var pageCount = (items.Count / itemsPerPage) + 1;
|
||||
|
@ -18,5 +18,7 @@ namespace PluralKit.Bot {
|
||||
public static PKError BirthdayParseError(string birthday) => new PKError($"\"{birthday}\" could not be parsed as a valid date. Try a format like \"2016-12-24\" or \"May 3 1996\".");
|
||||
public static PKError ProxyMustHaveText => new PKSyntaxError("Example proxy message must contain the string 'text'.");
|
||||
public static PKError ProxyMultipleText => new PKSyntaxError("Example proxy message must contain the string 'text' exactly once.");
|
||||
|
||||
public static PKError MemberDeleteCancelled => new PKError($"Member deletion cancelled. Stay safe! {Emojis.ThumbsUp}");
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ namespace PluralKit.Bot
|
||||
public PKSystem System;
|
||||
public string InnerText;
|
||||
|
||||
public string ProxyName => Member.Name + (System.Tag.Length > 0 ? " " + System.Tag : "");
|
||||
public string ProxyName => Member.Name + (System.Tag != null ? " " + System.Tag : "");
|
||||
}
|
||||
|
||||
class ProxyService {
|
||||
|
@ -101,5 +101,6 @@ namespace PluralKit
|
||||
public static readonly string Success = "\u2705";
|
||||
public static readonly string Error = "\u274C";
|
||||
public static readonly string Note = "\u2757";
|
||||
public static readonly string ThumbsUp = "\U0001f44d";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user