public Task <Result> Execute(SocketUserMessage e) { SocketGuildChannel channel = (e.Author as SocketGuildUser).VoiceChannel; if (channel != null) { Voice.VoiceChannel vc = Voice.allVoiceChannels [channel.Id]; if (vc.IsLocked()) { if (vc.lockerID == e.Author.Id) { vc.Unlock(true); return(TaskResult(vc, "Succesfully unlocked voice channel **" + vc.GetName() + "**.")); } return(TaskResult(vc, "Only the person who locked this channel can do that, which is " + vc.GetLocker().Mention)); } return(TaskResult(vc, "Failed to unlock voice channel **" + vc.GetName() + "** - It is not unlocked.")); } return(TaskResult(null, "Failed to unlock channel, are you even in one?")); }
public Task <Result> Execute(SocketUserMessage e, string username) { SocketGuildChannel channel = (e.Author as SocketGuildUser).VoiceChannel; SocketGuildUser user = Utility.FindUserByName((e.Channel as SocketGuildChannel).Guild, username); if (user == null) { return(TaskResult(false, "Error - User not found.")); } if (channel != null) { Voice.VoiceChannel vc = Voice.allVoiceChannels [channel.Id]; if (vc.IsLocked()) { if (vc.lockerID == e.Author.Id) { if (user.GuildPermissions.ManageChannels) { return(TaskResult(false, "Nice try, but you can't kick admins >:D.")); } vc.Kick(user); Program.messageControl.SendMessage(user, "Sorry man, but you have been kicked from voice channel **" + vc.GetName() + "**."); return(TaskResult(true, "User **" + Utility.GetUserName(user) + "** succesfully kicked.")); } return(TaskResult(false, "Only the person who locked this channel can do that, which is " + vc.GetLocker().Mention)); } return(TaskResult(false, "Error - The channel isn't locked.")); } return(TaskResult(false, "Error - Are you even in a channel?")); }