Example #1
0
        protected override async Task Execute(IMessage message, string parameter)
        {
            var service = Bot.Instance.ServiceManager.GetService <VoiceChannelRentingService>();
            var guild   = Bot.Instance.ServiceManager.GetService <SingleServerInfoProviderService>().Guild;

            try
            {
                var currentChannel = ((IGuildUser)message.Author).VoiceChannel;
                var rentingChannel = guild.GetVoiceChannel(service.Config.RentedChannels.Find(channel => channel.Id == currentChannel.Id).ParentChannelId);
                VoiceChannelRenting.RemoveRentingChannel(rentingChannel);
                await message.Channel.SendMessageAsync($"{message.Author.Mention} channel removed!");
            }
            catch
            {
                await message.Channel.SendMessageAsync($"{message.Author.Mention} channel is not a renting channel!");
            }
        }
Example #2
0
        protected override async Task Execute(IMessage message, string parameter)
        {
            var match = Regex.Match(parameter, @"^(.+)$");

            try
            {
                VoiceChannelRenting.AddRentingChannel(((IGuildUser)message.Author).VoiceChannel, match.Result("$1"));
                await message.Channel.SendMessageAsync($"{message.Author.Mention} channel added!");
            }
            catch (RentingChannelException)
            {
                await message.Channel.SendMessageAsync($"{message.Author.Mention} channel already is a renting channel!");
            }
            catch
            {
                await message.Channel.SendMessageAsync($"{message.Author.Mention} invalid parameters!");
            }
        }