コード例 #1
0
        public async Task <RuntimeResult> PMChannel(IMessageChannel channel, [Remainder] string message)
        {
            try
            {
                if (_messagingService.MassDMInProgress)
                {
                    throw new Exception("Mass DM operation is in progress, please wait for it to finish");
                }
                var urls = await _trackerService.GetTrackerUrls(
                    Context.User,
                    channel,
                    message);

                var pms = urls.Select(kv => new PrivateMessage(kv.Key, FormatMessage(kv.Value))).ToArray();
                await _messagingService.MassDM(Context.Channel, pms);

                return(CommandResult.FromSuccess());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(CommandResult.FromError(ex.Message));
            }
        }