#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task Leave() #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { var card = new SetupCard(null, true, new string[] { "cancel" }, null); CardStackManager.CreateCardStack(card, Context.Message); }
private async Task ProcessMessage(SocketUserMessage message) { //var context = new SocketCommandContext(_client, message); try { // check if there is a card on the stack that can handle the // message, and if so - send it there instead if (CardStackManager.RouteMessage(message)) { return; } else if (message.Channel is SocketTextChannel tch) { var guildUser = message.Author as IGuildUser; var guildConfig = BotConfiguration.GetGuildConfiguration(tch.Guild); // if configuration for this guild was not found, fuggedaboudit if (guildConfig == null) { return; } int argPos = 0; // check if the message has the command prefix var hasCommandPrefix = message.HasCharPrefix(guildConfig.CommandPrefix, ref argPos); // check if the message starts with the mention prefix var hasMentionPrefix = message.HasMentionPrefix(Client.CurrentUser, ref argPos); // don't process messages that have the mention or command prefix if (!hasCommandPrefix && !hasMentionPrefix) { return; } string messageText = message.Content
public async Task Poll(params string[] options) { string duration = (options.Length > 0) ? (options[0] ?? string.Empty).ToLower().Trim() : string.Empty; string question = (options.Length > 1) ? string.Join(" ", options.Skip(1)) : string.Empty; bool hasPoll = _pollTracker.UserHasActivePoll(Context.User, Context.Channel); duration = duration?.ToLower().Trim(); if (hasPoll) { await ReplyAsync("You already have a poll active on this channel, and cannot create another."); } else if (string.IsNullOrWhiteSpace(duration)) { await ReplyAsync("You need to provide a duration and a question to start a poll. Duration may be either 5m, 10m, or 15m"); } else if (duration != "1m" && duration != "5m" && duration != "10m" && duration != "15m") { await ReplyAsync("Duration may only be set to 5, 10, or 15 minutes by specifying 5m, 10m, or 15m respectively."); } else if (string.IsNullOrWhiteSpace(question)) { await ReplyAsync("You need to provide a question to start a poll."); } else { TimeSpan durationTimeSpan = new TimeSpan(0, 1, 0); if (duration == "5m") { durationTimeSpan = new TimeSpan(0, 5, 0); } if (duration == "10m") { durationTimeSpan = new TimeSpan(0, 10, 0); } else if (duration == "15m") { durationTimeSpan = new TimeSpan(0, 15, 0); } PollOptionsCard card = new PollOptionsCard(question, true, this._pollTracker, durationTimeSpan, new string[] { "--done--" }, new string[] { "cancel" }); CardStackManager.CreateCardStack(card, Context.Message); } }