public static async Task PerformAsync(ShardedCommandContext context, string replyKey, string message, bool replyable, DataBase db) { var candidateGuilds = Send.GuildList(context); var key = LoadConfig.Instance.config["encryptionKey"]; var candidateId = Rijndael.Decrypt(replyKey, key, KeySize.Aes256); // TODO: potentially want to bake guilds into reply codes so we can ensure that the the replier isn't banned on the server where the original // message was sent var users = SendDirectMessage.ToUserList(candidateGuilds).Where(x => x.Id.ToString() == candidateId); if (users.Count() == 0) { await Send.SendErrorWithDeleteReaction(context, "Something is wrong with that reply code. It is possible the sender has left your server."); return; } var allowedGuild = users.ToList().Select(x => FindOrCreateGuild.Perform(x.Guild, db)).FirstOrDefault(x => !PrefixHelper.UserBlocked(context, x)); if (allowedGuild == null) { await context.Channel.SendMessageAsync("It appears that you have been banned from using Voltaire on the targeted server. If you think this is an error, contact one of your admins."); return; } var prefix = $"{PrefixHelper.ComputePrefix(context, allowedGuild, "someone")} replied"; // all 'users' hera are technically the same user, so just take the first var channel = await users.First().GetOrCreateDMChannelAsync(); var messageFunction = Send.SendMessageToChannel(channel, replyable, context.User); await messageFunction(prefix, message); await Send.SendSentEmote(context); await Send.SendSentEmote(context); }
public static async Task PerformAsync(SocketCommandContext context, string replyKey, string message, DataBase db) { var candidateGuilds = Send.GuildList(context); var key = LoadConfig.Instance.config["encryptionKey"]; var candidateId = Rijndael.Decrypt(replyKey, key, KeySize.Aes256); var user = SendDirectMessage.ToUserList(candidateGuilds).Where(x => x.Id.ToString() == candidateId).FirstOrDefault(); if (user == null) { await context.Channel.SendMessageAsync("Something is wrong with that reply code. It is possible the sender has left your server."); return; } var userGuild = FindOrCreateGuild.Perform(user.Guild, db); var prefix = PrefixHelper.ComputePrefix(context, userGuild, "someone"); var channel = await user.GetOrCreateDMChannelAsync(); await channel.SendMessageAsync($"{prefix} replied: {message}"); }