示例#1
0
        public static async Task <ServerConnection> CreateAsync(IMessageChannel channel, GameServer server, ConnectionProperties properties = null)
        {
            properties ??= ConnectionProperties.Default;
            IUserMessage message = await channel.SendMessageAsync(server.GetBroadcast(properties.Frequency)?.ToString() ?? $"> ⚠️ Could not find a channel at the specified frequency ({properties.Frequency}).");

            return(new ServerConnection
            {
                Server = server,
                Frequency = properties.Frequency,
                State = properties.State,
                RefreshRate = properties.RefreshRate,
                RefreshCounter = properties.AutoRefreshCounter,
                BlockInput = properties.BlockInput,
                ContentOverride = properties.ContentOverride,
                Inputs = properties.Inputs,
                Channel = channel,
                ChannelId = channel.Id,
                MessageId = message.Id,
                Message = message,
                DeleteMessages = properties.CanDeleteMessages,
                LastRefreshed = DateTime.UtcNow
            });
        }