private async Task VoiceKickUserAsync(SocketGuildUser user) { SocketVoiceChannel currentVc = user.VoiceChannel; RestVoiceChannel vcChannel = await ServerData.Server.CreateVoiceChannelAsync("Temporary"); await user.ModifyAsync(x => x.Channel = vcChannel); await vcChannel.DeleteAsync(); if (user.Nickname != null) { await ReplyAsync(BotUtils.KamtroText($"{user.Nickname} has been removed from {currentVc.Name}.")); } else { await ReplyAsync(BotUtils.KamtroText($"{user.Username} has been removed from {currentVc.Name}.")); } }
public async Task clear() { Console.WriteLine(Context.Message.Author.Username); if (Context.Message.Author.Username == "hex") { await Context.Channel.SendMessageAsync(Context.Message.Author.Mention + " Clearing all objects..."); //iterate through groups and delete everything ArrayList groups = (ArrayList)SaveGroup.get(); int count = groups.Count; if (count != 0) { for (int i = 0; i < count; i++) { Group group = (Group)groups[i]; //delete group role IRole role = group.getRole(); Console.WriteLine("Role: " + role); //group role can not exist try { await role.DeleteAsync(); } catch (Exception e) { } //delete creator role IRole creatorRole = group.getCreatorRole(); Console.WriteLine("Creator Role: " + creatorRole); await creatorRole.DeleteAsync(); //delete group channel RestVoiceChannel channel = group.getChannel(); Console.WriteLine("Channel: " + channel); //channel can not exist try { await channel.DeleteAsync(); } catch (Exception e) { } //Store empty group object SaveGroup.store(new ArrayList()); } await Context.Channel.SendMessageAsync(Context.Message.Author.Mention + " Cleared succesfully!"); } else { await Context.Channel.SendMessageAsync(Context.Message.Author.Mention + " Nothing to clear."); } } else { //INVALID USER await Context.Channel.SendMessageAsync(Context.Message.Author.Mention + " Error: You are not my creator..."); } }
private async Task JoinChannel(SocketVoiceChannel channel, SocketGuildUser user) { if (channel == null) { return; } var failed = false; RestVoiceChannel newChannel = null; try { var auto = await _channel.Load(channel.Guild.Id, AutomationType.Temporary); if (channel.Name.StartsWith(auto.Prefix, StringComparison.OrdinalIgnoreCase)) { newChannel = await DuplicateChannel(channel, user, auto.Name); await _channel.AddGeneratedChannel(channel.Guild.Id, newChannel.Id); _channels.Remove(newChannel.Id); return; } var perma = await _channel.Load(channel.Guild.Id, AutomationType.Permanent); if (channel.Name.StartsWith(perma.Prefix, StringComparison.OrdinalIgnoreCase)) { newChannel = await DuplicateChannel(channel, user, perma.Name); _channels.Remove(newChannel.Id); } } catch (HttpException httpException) { if (!httpException.Message.Contains("error 50013: Missing Permissions")) { await Logs.Write("Crashes", $"JoinChannel crashed. ({channel.Guild.Id}) {channel.Id}, {channel.Name}.", httpException); } else { var pmChannel = await channel.Guild.Owner.GetOrCreateDMChannelAsync(); await LoadLanguage(channel.Guild.Id); await pmChannel.SendMessageAsync(_localization.GetMessage("Channel no permission", channel.Guild.Name, channel.Name)); } failed = true; } catch (Exception e) { await Logs.Write("Crashes", $"JoinChannel crashed. ({channel.Guild.Id}) {channel.Id}, {channel.Name}.", e); failed = true; } if (failed) { if (newChannel != null) { await newChannel.DeleteAsync(); try { await _channel.RemoveGeneratedChannel(newChannel.GuildId, newChannel.Id); } catch (Exception) { //ignore } _channels.Remove(newChannel.Id); } } }