Implement success message formatting
Imported from `legacy` branch: RegexBot/RegexBot/Module/AutoMod/ResponseBase.cs:161
This commit is contained in:
parent
495636baec
commit
634bc26951
3 changed files with 14 additions and 6 deletions
|
@ -14,8 +14,8 @@ class Ban : BanKick {
|
||||||
// Ban: Unlike kick, the minimum required is just the target ID
|
// Ban: Unlike kick, the minimum required is just the target ID
|
||||||
var result = await Module.Bot.BanAsync(g, msg.Author.ToString(), targetId, PurgeDays, reason, SendNotify);
|
var result = await Module.Bot.BanAsync(g, msg.Author.ToString(), targetId, PurgeDays, reason, SendNotify);
|
||||||
if (result.OperationSuccess && SuccessMessage != null) {
|
if (result.OperationSuccess && SuccessMessage != null) {
|
||||||
// TODO string replacement, formatting, etc
|
var success = ProcessText(SuccessMessage, msg);
|
||||||
await msg.Channel.SendMessageAsync($"{SuccessMessage}\n{result.GetResultString(Module.Bot)}");
|
await msg.Channel.SendMessageAsync($"{success}\n{result.GetResultString(Module.Bot)}");
|
||||||
} else {
|
} else {
|
||||||
await msg.Channel.SendMessageAsync(result.GetResultString(Module.Bot));
|
await msg.Channel.SendMessageAsync(result.GetResultString(Module.Bot));
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ class Kick : BanKick {
|
||||||
|
|
||||||
var result = await Module.Bot.KickAsync(g, msg.Author.ToString(), targetId, reason, SendNotify);
|
var result = await Module.Bot.KickAsync(g, msg.Author.ToString(), targetId, reason, SendNotify);
|
||||||
if (result.OperationSuccess && SuccessMessage != null) {
|
if (result.OperationSuccess && SuccessMessage != null) {
|
||||||
// TODO string replacement, formatting, etc
|
var success = ProcessText(SuccessMessage, msg);
|
||||||
await msg.Channel.SendMessageAsync($"{SuccessMessage}\n{result.GetResultString(Module.Bot)}");
|
await msg.Channel.SendMessageAsync($"{success}\n{result.GetResultString(Module.Bot)}");
|
||||||
} else {
|
} else {
|
||||||
await msg.Channel.SendMessageAsync(result.GetResultString(Module.Bot));
|
await msg.Channel.SendMessageAsync(result.GetResultString(Module.Bot));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,12 @@ abstract class CommandConfig {
|
||||||
};
|
};
|
||||||
await target.SendMessageAsync(message ?? "", embed: usageEmbed.Build());
|
await target.SendMessageAsync(message ?? "", embed: usageEmbed.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static string ProcessText(string input, SocketMessage m) {
|
||||||
|
// TODO elaborate on this
|
||||||
|
// For now, replaces all instances of @_ with the message sender.
|
||||||
|
return input
|
||||||
|
.Replace("@_", m.Author.Mention)
|
||||||
|
.Replace("@\\_", "@_");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,8 @@ class Timeout : CommandConfig {
|
||||||
var result = await Module.Bot.SetTimeoutAsync(g, msg.Author.AsEntityNameString(), targetUser,
|
var result = await Module.Bot.SetTimeoutAsync(g, msg.Author.AsEntityNameString(), targetUser,
|
||||||
TimeSpan.FromMinutes(timeParam), reason, SendNotify);
|
TimeSpan.FromMinutes(timeParam), reason, SendNotify);
|
||||||
if (result.Success && SuccessMessage != null) {
|
if (result.Success && SuccessMessage != null) {
|
||||||
// TODO string replacement, formatting, etc
|
var success = ProcessText(SuccessMessage, msg);
|
||||||
await msg.Channel.SendMessageAsync($"{SuccessMessage}\n{result.ToResultString()}");
|
await msg.Channel.SendMessageAsync($"{success}\n{result.ToResultString()}");
|
||||||
} else {
|
} else {
|
||||||
await msg.Channel.SendMessageAsync(result.ToResultString());
|
await msg.Channel.SendMessageAsync(result.ToResultString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue