Пример #1
0
            public async Task <Result> Execute(SocketUserMessage e, string name, string timespan)
            {
                TimeSpan timeSpan;

                if (Utility.TryParseSimpleTimespan(timespan, out timeSpan))
                {
                    Voice.VoiceChannel channel = await Voice.CreateTemporaryChannel(name, timeSpan);

                    return(new Result(channel, "Succesfully created voice channel by name **" + name + "**!"));
                }
                else
                {
                    return(new Result(null, "Failed to create voice channel - TimeSpan could not be parsed."));
                }
            }
Пример #2
0
        public static void StartEvent(Event startingEvent)
        {
            Logging.Log(Logging.LogType.BOT, "Starting event: " + startingEvent.name + "!");
            startingEvent.eventState = Event.EventState.InProgress;
            AutoCommands.RunEvent(AutoCommands.Event.EventStarted, startingEvent.name);

            if (startingEvent.eventMemberIDs.Count != 0)
            {
                string mentions = "";
                foreach (ulong id in startingEvent.eventMemberIDs)
                {
                    SocketGuildUser user = Utility.GetServer().GetUser(id);
                    if (user != null)
                    {
                        mentions += ", " + user.Mention;
                    }
                }

                if (startingEvent.eventMemberIDs.Count > 0)
                {
                    string members;
                    Embed  eventEmbed = ConstructEmbed(startingEvent, out members);
                    Program.messageControl.SendEmbed(Utility.GetMainChannel() as SocketTextChannel, eventEmbed, members);
                    Voice.CreateTemporaryChannel(startingEvent.name, startingEvent.duration);
                    ongoingEvents.Add(startingEvent);
                }
                else
                {
                    try {
                        Program.messageControl.SendMessage(
                            Utility.GetMainChannel() as SocketTextChannel,
                            "Event **" + startingEvent.name + "** cancelled, since no one showed up. :(", true);
                        startingEvent.eventState = Event.EventState.Ended;
                    }catch (Exception e) {
                        Logging.Log(e);
                    }
                }

                if (startingEvent.repeatTime.Ticks != 0)
                {
                    Event evt = CreateAndReturnEvent(startingEvent.name, startingEvent.time.Add(startingEvent.repeatTime), startingEvent.duration, startingEvent.hostID, startingEvent.iconUrl, startingEvent.description, startingEvent.repeatTime);
                    evt.eventMemberIDs = startingEvent.eventMemberIDs;
                    toAdd.Add(evt);
                }
            }
        }