public async Task Break(CommandContext commandContext) { var server = commandContext.Guild; ClassTimeSettings localSettings = null; if (LocalSettings.TryGetValue(server, out localSettings)) { localSettings.Break(); await commandContext.Message.CreateReactionAsync(MePhItBot.Bot.ReactSuccess); } else { await commandContext.Message.CreateReactionAsync(MePhItBot.Bot.ReactFail); } }
public async Task Start(CommandContext commandContext, [Description("Канал для вывода информационных сообщений")] DiscordChannel channel = null, // Channel to output info messages [Description("Длительность занятия в минутах")] int durationTimeInMinutes = 150, // class longivity [Description("Время до начала перерыва в минутах")] int timeTillBreakInMinutes = 60, // time before the break begins [Description("Длительность перерыва в минутах")] int breakDurationInMinutes = 15, // break time length [Description("Время в минутах до конца занятия для уведомления об окончании занятия")] int notifyBeforeEventInMinutes = 5) // ahead notify about the break and about the class end { ClassTimeSettings localSettings = null; channel = channel == null ? commandContext.Channel : channel; var server = commandContext.Guild; if (!LocalSettings.TryGetValue(server, out localSettings)) { localSettings = new ClassTimeSettings(LocalSettings, channel, durationTimeInMinutes, timeTillBreakInMinutes, breakDurationInMinutes, notifyBeforeEventInMinutes); localSettings.Start(); LocalSettings.Add(server, localSettings); await commandContext.Message.CreateReactionAsync(MePhItBot.Bot.ReactSuccess); } else { localSettings.ClassTimeInMinutes = durationTimeInMinutes; localSettings.TimeTillBreakInMinutes = timeTillBreakInMinutes; localSettings.BreakDurationInMinutes = breakDurationInMinutes; localSettings.NotifyBeforeClassEndInMinutes = notifyBeforeEventInMinutes; localSettings.Start(); await commandContext.Message.CreateReactionAsync(MePhItBot.Bot.ReactSuccess); return; } }