Beispiel #1
0
        public async Task UnLock(SocketGuildChannel channel)
        {
            if (channel == null)
            {
                await ReplyAsync("Channel not specified!\n+lock [channel]");

                return;
            }

            await channel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, new OverwritePermissions(sendMessages : PermValue.Allow));
        }
        public async Task RemoveFromChannel(
            [Summary("The user to remove")] SocketGuildUser user,
            [Summary("The channel to add to")] SocketGuildChannel channel)
        {
            List <ulong> mods = await GranularPermissionsStorage.GetChannelmodsFor(this.Context.Guild.Id, channel as ISocketMessageChannel);

            if (!mods.Contains(this.Context.User.Id))
            {
                await this.Context.Channel.SendMessageAsync("You're not a channelmod of this channel: **" + channel.Name + "**");

                return;
            }

            await channel.AddPermissionOverwriteAsync(user,
                                                      new OverwritePermissions(readMessages : PermValue.Deny, sendMessages : PermValue.Deny));

            await this.Context.Message.AddReactionAsync(new Emoji("👌"));
        }
        public async Task mute()
        {
            IReadOnlyCollection <SocketRole> Roles = Context.Guild.GetUser(Context.User.Id).Roles;
            var EventOrg = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Event Organizer");
            var host     = Context.Guild.Roles.FirstOrDefault(x => x.Name == "host");

            List <SocketRole> userroles = Roles.ToList();

            if (userroles.Contains(EventOrg) == true)
            {
                IReadOnlyCollection <SocketGuildUser> Users = Context.Guild.VoiceChannels.FirstOrDefault(x => x.Name == "Events" || x.Name == "Open Mic" || x.Name == "🏆Events🏆" || x.Name == "Event" || x.Name == "Karaoke" || x.Name == "🎤Open Mic🎤" || x.Name == "Event Voice Chat").Users;
                SocketGuildChannel     EventChannel         = Context.Guild.VoiceChannels.FirstOrDefault(x => x.Name == "Events" || x.Name == "Open Mic" || x.Name == "🏆Events🏆" || x.Name == "Event" || x.Name == "Karaoke" || x.Name == "🎤Open Mic🎤" || x.Name == "Event Voice Chat");
                List <SocketGuildUser> SocketUsers          = Users.ToList();
                foreach (SocketGuildUser user in SocketUsers)
                {
                    new OverwritePermissions(speak: PermValue.Deny);
                    var MuteRole     = Context.Guild.Roles.FirstOrDefault(x => x.Name == "EventMute");
                    var EveryoneRole = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Member");
                    await user.ModifyAsync(x => x.Mute = true);

                    await((SocketGuildUser)Context.User).ModifyAsync(x => x.Mute = false);
                    await EventChannel.AddPermissionOverwriteAsync(EveryoneRole, new OverwritePermissions(speak : PermValue.Deny));
                }
                var embed = new EmbedBuilder();
                embed.WithTitle("**Mute!**");
                embed.WithDescription("Users in the channel have been muted!");
                embed.WithColor(new Color(129, 127, 255));
                embed.WithThumbnailUrl(Context.Guild.IconUrl);

                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
            else
            {
                var embed = new EmbedBuilder();
                embed.WithTitle("**Sorry!**");
                embed.WithDescription("You're not an event organizer!");
                embed.WithColor(new Color(129, 127, 255));
                embed.WithThumbnailUrl(Context.User.GetAvatarUrl());

                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
        }
Beispiel #4
0
        public bool AddUserToScumChat(SocketGuild guild, SocketGuildUser user)
        {
            SocketGuildChannel scumChat = null;

            foreach (SocketGuildChannel channel in guild.Channels)
            {
                if (channel.Name == "mafia-scum-chat")
                {
                    scumChat = channel;
                }
            }

            if (scumChat != null)
            {
                scumChat.AddPermissionOverwriteAsync(user, new OverwritePermissions(viewChannel: PermValue.Allow, sendMessages: PermValue.Allow, readMessageHistory: PermValue.Allow));
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public async Task UnlockChannelRemote(SocketGuildChannel channel = null)
        {
            channel = channel ?? (SocketGuildChannel)Context.Channel;
            if (!(Context.User is SocketGuildUser userSend) ||
                !userSend.GuildPermissions.ManageChannels)
            {
                await Utils.SendInvalidPerm(Context.User, Context.Channel);

                return;
            }

            var role = Context.Guild.EveryoneRole;
            await channel.AddPermissionOverwriteAsync(role, OverwritePermissions.InheritAll);

            var builder = new EmbedBuilder()
                          .WithDescription("`Channel unlocked`");

            if (!(Context.Client.GetChannel(channel.Id) is SocketTextChannel channelId))
            {
                return;
            }
            await channelId.SendMessageAsync(null, false, builder.Build());
        }
 public virtual Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions?options = null)
 {
     return(_socketGuildChannel.AddPermissionOverwriteAsync(role, permissions, options));
 }
Beispiel #7
0
 public async Task SetChannelViewPermissionAsync(IUser user, SocketGuildChannel channel, bool hide)
 {
     var value = hide ? PermValue.Deny : PermValue.Allow;
     await channel.AddPermissionOverwriteAsync(user, new OverwritePermissions(viewChannel : value));
 }