Example #1
0
        private async Task <InhouseQueue> GetQueue(string queueName)
        {
            var queues = Context.Database.GetCollection <InhouseQueue>();
            var queue  = await InhouseQueue.GetQueueAsync(Context.Channel.Id, queueName, Context.Client, queues);

            if (queue == null)
            {
                throw new ArgumentException("Did not find any current inhouse queue for this channel.");
            }
            return(queue);
        }
Example #2
0
        private async Task DeleteQueue(string queueName)
        {
            var queues = Context.Database.GetCollection <InhouseQueue>();

            var existing = await InhouseQueue.GetQueueAsync(Context.Channel.Id, queueName, Context.Client, queues);

            if (existing != null)
            {
                queues.Delete(existing.Name);
                await Context.Channel.SendMessageAsync($"Queue {queueName} deleted.");
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Queue {queueName} not found in this channel.");
            }
        }
Example #3
0
        private async Task <InhouseQueue> CreateQueue(string queueName)
        {
            var newQueue = new InhouseQueue(Context.Channel.Id, queueName);

            var queues = Context.Database.GetCollection <InhouseQueue>();

            // Delete current queue if exists
            try
            {
                var existing = await InhouseQueue.GetQueueAsync(Context.Channel.Id, queueName, Context.Client, queues);

                if (existing != null)
                {
                    queues.Delete(existing.Name);
                }
            }
            catch (Exception) { }

            // Insert into DB
            queues.Insert(newQueue);
            queues.EnsureIndex(x => x.Name);

            return(newQueue);
        }