2022-07-18 23:44:31 +00:00
|
|
|
|
using RegexBot.Common;
|
|
|
|
|
|
|
|
|
|
namespace RegexBot.Modules.ModCommands.Commands;
|
|
|
|
|
class Say : CommandConfig {
|
|
|
|
|
private readonly string _usage;
|
|
|
|
|
protected override string DefaultUsageMsg => _usage;
|
|
|
|
|
|
|
|
|
|
// No configuration at the moment.
|
|
|
|
|
// TODO: Whitelist/blacklist - to limit which channels it can "say" into
|
|
|
|
|
public Say(ModCommands module, JObject config) : base(module, config) {
|
|
|
|
|
_usage = $"{Command} `channel` `message`\n"
|
|
|
|
|
+ "Displays the given message exactly as specified to the given channel.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async Task Invoke(SocketGuild g, SocketMessage msg) {
|
2024-06-09 04:08:03 +00:00
|
|
|
|
var line = SplitToParams(msg, 3);
|
2022-07-18 23:44:31 +00:00
|
|
|
|
if (line.Length <= 1) {
|
|
|
|
|
await SendUsageMessageAsync(msg.Channel, ":x: You must specify a channel.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (line.Length <= 2 || string.IsNullOrWhiteSpace(line[2])) {
|
|
|
|
|
await SendUsageMessageAsync(msg.Channel, ":x: You must specify a message.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-09 04:08:03 +00:00
|
|
|
|
var getCh = Utilities.ChannelMentionRegex().Match(line[1]);
|
2022-07-18 23:44:31 +00:00
|
|
|
|
if (!getCh.Success) {
|
|
|
|
|
await SendUsageMessageAsync(msg.Channel, ":x: Unable to find given channel.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var ch = g.GetTextChannel(ulong.Parse(getCh.Groups["snowflake"].Value));
|
|
|
|
|
await ch.SendMessageAsync(line[2]);
|
|
|
|
|
}
|
|
|
|
|
}
|