コード例 #1
0
ファイル: ChannelHelper.cs プロジェクト: XtremeOwnage/WarBot
        /// <summary>
        /// Finds the first channel, which is private to everybody, but, viewable by admins.
        /// </summary>
        /// <param name="Guild"></param>
        ///
        /// <returns></returns>
        public static async Task <ITextChannel> findFirstAdminChannel(SocketGuild Guild)
        {
            var ME = Guild.CurrentUser;

            //Next, Just loop through channels, until we find a writeable channel.
            foreach (SocketTextChannel tch in Guild.Channels.OfType <SocketTextChannel>())
            {
                //Simple stupid way. //ToDo - Add better logic in the future.
                //Summary - Find a channel we can write to, but, everybody cannot.
                if (!PermissionHelper.TestPermission(tch, ChannelPermission.ReadMessages, Guild.EveryoneRole) &&
                    ME.GetPermissions(tch).SendMessages)
                {
                    return(tch);
                }
            }

            //If, there are no writable channels. Lets create one?
            if (ME.GuildPermissions.ManageChannels && ME.GuildPermissions.SendMessages)
            {
                var newCh = await Guild.CreateTextChannelAsync("Admins");

                //Block EVERYONE role from all permissions related to this channel.
                await newCh.AddPermissionOverwriteAsync(Guild.EveryoneRole, OverwritePermissions.DenyAll(newCh));

                //Grant the highest role, all permissions.
                await newCh.AddPermissionOverwriteAsync(Guild.Roles.First(), OverwritePermissions.AllowAll(newCh));

                await newCh.SendMessageAsync(@"I was unable to find a channel to which I could sent leadership/officer messages to... So, I created this channel automatically.
I will leadership-related messages into this channel.");

                return(newCh);
            }

            return(null);
        }
コード例 #2
0
        public async Task CreateChannel(params string[] args)
        {
            var channel = await Context.Guild.CreateTextChannelAsync(Context.User.Username, properties =>
            {
                properties.Topic  = $"Private channel of user {Context.User.Username}";
                properties.IsNsfw = true;
                properties.Name   = Context.User.Username;
            },
                                                                     new RequestOptions()
            {
                AuditLogReason = $"{Context.User.Username} has created a new text channel",
                CancelToken    = CancellationToken.None,
                RetryMode      = RetryMode.AlwaysRetry,
                Timeout        = 1000,
                UseSystemClock = true
            });

            await channel.AddPermissionOverwriteAsync(Context.User, OverwritePermissions.AllowAll(channel),
                                                      RequestOptions.Default);


            var embed = new EmbedBuilder
            {
                Color = Color.Blue, Title = "Успех", Description = $"Канал {channel.Mention} создан"
            };

            await ReplyAsync("", false, embed.Build());
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Hakko78/A-Bot
        private async Task _client_UserVoiceStateUpdated(SocketUser arg1, SocketVoiceState arg2, SocketVoiceState arg3)
        {
            ulong GuildId   = 741794858339008602;
            ulong ChannelId = 741799885082329121;

            if (arg3.VoiceChannel.Id == ChannelId)
            {
                IVoiceChannel voiceChannel = await bot.GetGuild(GuildId).CreateVoiceChannelAsync("Nothing");

                IVoiceChannel channel = bot.GetGuild(GuildId).GetVoiceChannel(ChannelId);
                await voiceChannel.ModifyAsync(x =>
                {
                    x.Name       = arg1.Username;
                    x.Position   = bot.GetGuild(741794858339008602).GetVoiceChannel(741799885082329121).Position + 1;;
                    x.CategoryId = 741799684624089138;
                });

                IUser a = arg1;
                await voiceChannel.AddPermissionOverwriteAsync(a, OverwritePermissions.AllowAll(voiceChannel));

                CreatedId = channel.Id;
                var user = bot.GetGuild(GuildId).GetUser(arg1.Id);
                await user.ModifyAsync(User =>
                {
                    User.ChannelId = voiceChannel.Id;
                });
            }
        }
コード例 #4
0
        public async Task JoinedNewGuild(SocketGuild guild)
        {
            var   cmdPrefix = Servers.GetServer(guild).commandPrefix;
            var   owner     = guild.Owner;
            var   channels  = guild.Channels;
            var   kID       = ulong.TryParse(Config.bot.BotUserID, out ulong ID);
            IUser kaguya    = _client.GetUser(ID);
            await owner.GetOrCreateDMChannelAsync();

            await owner.SendMessageAsync($"Hey there, {owner.Username}, I am Kaguya! I will serve as your server's all-in-one Discord Bot solution complete with powerful administrative commands, " +
                                         $"in-depth customizable logging, leveling/currency systems, osu! related commands, and more! Before we continue please read the following statement from my creator as it contains very " +
                                         $"helpful information on how to use me!" +
                                         $"\n" +
                                         $"\nGreetings, **The very first thing you should do as the server owner is move Kaguya's role to the highest position in your role list. Else, the bot may not work for your server!!** " +
                                         $"Second, the first command `({cmdPrefix}exp)` for example, may be very slow, as Kaguya has to update all channel permissions to allow for her use in your server. Do not make any changes " +
                                         $"to these permissions. " +
                                         $"Next, I recommend you check out the `{cmdPrefix}help` and `{cmdPrefix}helpdm` commands before continuing. If you have any troubles using Kaguya, resort to these commands!" +
                                         $"\nIn addition, Kaguya's default prefix is `$`. If you have another bot that uses `$`, don't worry as her prefix is fully customizable (up to two characters). In chat, tag Kaguya (`@Kaguya#2708`) " +
                                         $"and type `prefix <new prefix>` to edit her prefix. This way, you won't accidentally change the prefix of another bot that also uses the `$` symbol. If you ever wish to reset your prefix " +
                                         $"back to the default, tag Kaguya and type `prefix` with nothing else." +
                                         $"\nExamples of how to edit and reset the prefix: " +
                                         $"\n`@Kaguya#2708 prefix k!` (<-- Sets prefix to `k!`)" +
                                         $"\n`@Kaguya#2708 prefix` (<-- Prefix has been reset from `<old prefix>` to `$`)" +
                                         $"\n" +
                                         $"\nFinally, if you wish to report a bug, please go to the Kaguya github page (found through `{cmdPrefix}helpdm`) and create an issue." +
                                         $"\nYou may also let me know in Kaguya's dedicated support server: https://discord.gg/yhcNC97" +
                                         $"\n" +
                                         $"\nThank you, and enjoy!");

            var server = Servers.GetServer(guild);

            foreach (SocketTextChannel channel in guild.TextChannels)
            {
                if (!channel.GetPermissionOverwrite(kaguya as SocketGuildUser).HasValue&& server.IsBlacklisted == false)
                {
                    try
                    {
                        await channel.AddPermissionOverwriteAsync(kaguya, OverwritePermissions.AllowAll(channel));

                        logger.ConsoleGuildAdvisory(guild, channel, $"Kaguya has been granted permissions for channel #{channel.Name}");
                    }
                    catch (Exception exception)
                    {
                        logger.ConsoleStatusAdvisory($"Could not overwrite permissions for #{channel.Name} in guild \"{channel.Guild.Name}\"");
                        logger.ConsoleCriticalAdvisory(exception, $"Guild {guild.Name} has been blacklisted.");

                        await guild.Owner.SendMessageAsync($"**This server has been blacklisted because I was unable to alter text channel permissions." +
                                                           $"\nPlease contact Stage#0001 in my support server (https://discord.gg/yhcNC97) to be unblacklisted!**");

                        server.IsBlacklisted = true;
                    }
                }
            }

            server.ID         = guild.Id;
            server.ServerName = guild.Name;
            Servers.SaveServers();
            logger.ConsoleGuildConnectionAdvisory(guild, "Joined new guild");
        }
コード例 #5
0
        public async Task CreateVoiceChannel(int maxSize = 5, string name = null)
        {
            var user = UserAccounts.GetAccount(Context.User, 0);

            if (maxSize > 99)
            {
                maxSize = 99;
            }
            if (user.VoiceChannelList.Count >= 1)
            {
                await ReplyAsync($"You already have a channel.");

                return;
            }

            if (name == null)
            {
                name = $"{Context.User.Username}-Channel";
            }
            else
            {
                if (name.Length > 30)
                {
                    name = $"{Context.User.Username}-Channel";
                }
            }

            var category     = Context.Channel as ITextChannel;
            var voiceChannel = await Context.Guild.CreateVoiceChannelAsync(name, prop =>
            {
                prop.UserLimit  = maxSize;
                prop.Bitrate    = 64000;
                prop.Name       = name;
                prop.CategoryId = category?.GetCategoryAsync().Result.Id;
            });

            await voiceChannel.AddPermissionOverwriteAsync(Context.User, OverwritePermissions.AllowAll(voiceChannel),
                                                           RequestOptions.Default);


            if (category != null)
            {
                var newVoice =
                    new AccountSettings.CreateVoiceChannel(DateTime.UtcNow, voiceChannel.Id, category.Guild.Id);
                user.VoiceChannelList.Add(newVoice);
                UserAccounts.SaveAccounts(0);
            }
            else
            {
                await ReplyAsync("error.");

                return;
            }

            await ReplyAsync(
                $"Voice Channel have been Created, please join it, or I will delete it in 10 min\n" +
                $"{voiceChannel.CreateInviteAsync().Result.Url}");
        }
コード例 #6
0
        private void CheckToDeleteVoice(object sender, ElapsedEventArgs e)
        {
            var allUserAccounts = _accounts.GetAllAccount();

            foreach (var t in allUserAccounts)
            {
                try
                {
                    var globalAccount = _global.Client.GetUser(t.DiscordId);
                    var account       = _accounts.GetAccount(globalAccount);
                    if (account.VoiceChannelList.Count <= 0)
                    {
                        continue;
                    }

                    var difference = DateTime.UtcNow - account.VoiceChannelList[0].LastTimeLeftChannel;

                    if (difference.Minutes > 10)
                    {
                        var voiceChan = _global.Client.GetGuild(account.VoiceChannelList[0].GuildId)
                                        .GetVoiceChannel(account.VoiceChannelList[0].VoiceChannelId);

                        account.VoiceChannelList = new List <AccountSettings.CreateVoiceChannel>();


                        if (voiceChan.Users.Count <= 0)
                        {
                            voiceChan.DeleteAsync();
                        }
                        else if (voiceChan.Users.Count >= 1)
                        {
                            var usersList = voiceChan.Users.ToList();
                            var newHolder = _accounts.GetAccount(usersList[0]);

                            var newVoice = new AccountSettings.CreateVoiceChannel(DateTime.UtcNow.AddHours(10),
                                                                                  voiceChan.Id, voiceChan.Guild.Id);
                            newHolder.VoiceChannelList.Add(newVoice);

                            var guildUser = _global.Client.GetGuild(newHolder.VoiceChannelList[0].GuildId)
                                            .GetUser(newHolder.Id);
                            var k = voiceChan.AddPermissionOverwriteAsync(guildUser,
                                                                          OverwritePermissions.AllowAll(voiceChan),
                                                                          RequestOptions.Default);
                            var kk = voiceChan.RemovePermissionOverwriteAsync(globalAccount, RequestOptions.Default);
                        }
                    }
                }
                catch
                {
                    //
                }
            }
        }
コード例 #7
0
        public async Task StopProposalsAsync()
        {
            var photoBot = Service.PhotoBot;

            var winnerProposal = photoBot.Config.Proposals
                                 .OrderBy(element => Guid.NewGuid())
                                 .ThenByDescending(element => element.Score)
                                 .First();

            var proposalsChannel = photoBot.SocketGuild.GetTextChannel(photoBot.Config.CurrentProposalsChannelId);
            var winnersChannel   = photoBot.SocketGuild.GetTextChannel(photoBot.Config.WinnerChannelId);

            using var client = new WebClient();
            await client.DownloadFileTaskAsync(new Uri(winnerProposal.ImageUrl), "winner_proposal.png");

            try
            {
                await winnersChannel.SendFileAsync("winner_proposal.png", $"Thema: {winnerProposal.Topic}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            var users = photoBot.Config.PhotoUserIds;

            photoBot.Config.UserIdToPhotoChannelId = new Dictionary <ulong, ulong>();

            foreach (var userId in users)
            {
                var user         = photoBot.SocketGuild.GetUser(userId);
                var photoChannel = await ChannelCreator.CreateChannelAsync($"photo-{user.Username}", photoBot.Config.PhotoCategoryId);

                var denyAllPermissions = new Overwrite(photoBot.Config.EveryoneRoleId, PermissionTarget.Role,
                                                       OverwritePermissions.DenyAll(photoChannel));

                var allowUserPermissions = new Overwrite(userId, PermissionTarget.User,
                                                         OverwritePermissions.AllowAll(photoChannel));

                var permissions = new List <Overwrite> {
                    denyAllPermissions, allowUserPermissions
                };

                await photoChannel.ModifyAsync(prop => prop.PermissionOverwrites = permissions);

                photoBot.Config.UserIdToPhotoChannelId.Add(userId, photoChannel.Id);
            }

            await Archiver.ArchiveChannelAsync(proposalsChannel);

            await PhotoConfig.SaveAsync();
        }
コード例 #8
0
        private void Check_Channel_Permissions_Elapsed(object sender, ElapsedEventArgs e)
        {
            var        kID    = ulong.TryParse(Config.bot.BotUserID, out ulong ID);
            SocketUser kaguya = _client.GetUser(ID);

            if (kaguya != null)
            {
                var servers = Servers.GetAllServers();
                foreach (var server in servers.ToList())
                {
                    if (server.IsBlacklisted == false)
                    {
                        var id    = server.ID;
                        var guild = _client.GetGuild(id);
                        if (guild == null) //If the server returns null, delete it from the database.
                        {
                            logger.ConsoleCriticalAdvisory($"Guild returned null for {server.ID} [REMOVING!!], Timers.cs line 109.");
                            Servers.RemoveServer(server.ID);
                            continue;
                        }

                        int i = 0;

                        foreach (SocketTextChannel channel in guild.TextChannels)
                        {
                            if (!channel.GetPermissionOverwrite(kaguya).HasValue&& server.IsBlacklisted == false)
                            {
                                try
                                {
                                    channel.AddPermissionOverwriteAsync(kaguya, OverwritePermissions.AllowAll(channel));
                                    i++;
                                }
                                catch (Exception exception)
                                {
                                    logger.ConsoleStatusAdvisory($"Could not overwrite permissions for #{channel.Name} in guild \"{channel.Guild.Name}\"");
                                    logger.ConsoleCriticalAdvisory(exception, $"Guild {guild.Name} has been blacklisted.");
                                    server.IsBlacklisted = true;
                                }
                            }
                        }
                        logger.ConsoleGuildAdvisory($"Kaguya has been granted permissions for {i} new channels.");
                        continue;
                    }
                }
            }
            else
            {
                return;
            }
        }
コード例 #9
0
        private async Task <ITextChannel> CreateGuantanamoAsync(IRole role)
        {
            ITextChannel channel = await Context.Guild.CreateTextChannelAsync("guantanamo");

            OverwritePermissions perms = new(viewChannel : PermValue.Allow, sendMessages : PermValue.Allow, readMessageHistory : PermValue.Deny, addReactions : PermValue.Allow);

            await Task.WhenAll
            (
                channel.AddPermissionOverwriteAsync(role, perms),
                channel.AddPermissionOverwriteAsync(Context.Client.CurrentUser, OverwritePermissions.AllowAll(channel))
            );

            await channel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(channel));

            await modRolesDatabase.PrisonerChannel.SetPrisonerChannelAsync(channel);

            return(channel);
        }
コード例 #10
0
        public async Task Init()
        {
            if (States.state == States.StatesList[0])
            {
                GameChannel = await Context.Guild.CreateTextChannelAsync("NAVIGATION", null, null);

                await GameChannel.AddPermissionOverwriteAsync((IRole)Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(GameChannel));

                Navigator = await Context.Guild.CreateRoleAsync("Navigator", null, Color.Blue, false, null);

                await Context.Channel.SendMessageAsync("ALL PARTICIPATING AGENTS ENTER COMMAND !Join AND FIND 'NAVIGATION' CHANNEL", false, null);

                await GameChannel.AddPermissionOverwriteAsync((IRole)Navigator, OverwritePermissions.AllowAll(GameChannel));

                EmbedBuilder Embed = new EmbedBuilder();
                Embed.WithAuthor("DDA SYSTEMS");
                Embed.AddField(">>> START TRANSMISSION", "> TO ALL DDA INVESTIGATORS");
                Embed.AddField("> MISSION DETAILS:", "WE COLLABORATED WITH THE POLICE USING THE TECHNOLOGY HERE AT THE DIGITAL DATASCAPE AGENCY TO CREATE A DIGITAL COPY OF THE SUBJECT’S MEMORY. YOUR MISSION AS DDA INVESTIGATORS WILL HAVE YOU NAVIGATING THROUGH THE DIGITAL MINDSCAPE TO RESTORE THE SUBJECT’S MIND AND FIND THE RIGHT MEMORIES TO HELP SOLVE THE CASE. ");
                Embed.AddField("> SUBJECT '00003126'", "FLORENCE CARTER, ADDRESS: 2027 MEADOWLARK DR, CASTRO VALLEY, CA 94546, COUNTRY: USA, DOB: 7 / 14 / 1987, SEX: F, HEIGHT: 5’08");
                Embed.AddField("> DIAGNOSIS:", "SUBJECT IS SUFFERING BOTH RETROGRADE AND DISSOCIATIVE AMNESIA ONSET BY STRESS AND/OR TRAUMA. SUBJECT WAS FOUND IN THE PARKING LOT OF HER WORKPLACE, WANDERING AROUND IN A DISSOCIATIVE FUGUE. WHEN CONFRONTED BY A WORKER, SHE WAS UNABLE TO CONFIRM HER OWN IDENTITY. AFTER BEING ADMITTED TO THE HOSPITAL, HER IDENTITY WAS CONFIRMED. WHILE IN THE HOSPITAL, THE SUBJECT WAS ATTACKED BY AN UNKNOWN ASSAILANT. SHE SUFFERED MINIMAL INJURY. AFTERWARDS, THE POLICE WERE CALLED TO HER LOCATION. THE POLICE DETERMINED ______ BETWEEN THE SUBJECT AND AN ONGOING CASE REGARDING THE SERIAL KILLER _________ “THE ORPHANER”. THE SUBJECT WAS FOUND TO BE _____  ________ ______ OF A CLOSE FRIEND. HER ____________ AND _____ FRIEND’S ________ ________ FOUND MURDERED THE NEXT DAY, LEAVING BEHIND _____________ AGED ______. THERE IS A ______ POSSIBILITY THAT THE SUBJECT ____ ______ EVENTS ___________ WHICH CREATED _______ _______ ENOUGH _________________ ________");
                Embed.AddField("END TRANSMISSION <<<", "WE HIGHLY RECOMENDED ALL INVESTIGATORS REMAIN IN COMMUNICATION THROUGHOUT NAVIGATION");
                Embed.AddField("GOOD LUCK INVESTIGATORS", "TO BEGIN NAVIGATION, TYPE COMMAND !Ready");

                await GameChannel.SendMessageAsync("", false, Embed.Build(), null);

                States.isDead     = false;
                States.canPlace   = false;
                States.isPlaced   = false;
                States.bladesOn   = true;
                Room4.player1Free = false;
                Room4.player2Free = false;
                foreach (var item in States.Inventory)
                {
                    States.Inventory.Remove(item);
                }
                States.state = States.StatesList[1];
            }
        }
コード例 #11
0
        /// <summary>
        /// Resets the channel permissions for the given roleplay to their default values.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="roleplay">The roleplay.</param>
        /// <returns>A modification result which may or may not have succeeded.</returns>
        public async Task <ModifyEntityResult> ResetChannelPermissionsAsync(ITextChannel channel, Roleplay roleplay)
        {
            var guild = channel.Guild;

            // First, clear all overwrites from the channel
            var clear = await ClearChannelPermissionOverwrites(channel);

            if (!clear.IsSuccess)
            {
                return(clear);
            }

            // Next, apply default role settings
            var configureDefault = await ConfigureDefaultUserRolePermissions(guild, channel);

            if (!configureDefault.IsSuccess)
            {
                return(configureDefault);
            }

            // Finally, ensure the bot has full access to the channel
            var botDiscordUser = await guild.GetUserAsync(_client.CurrentUser.Id);

            var allowAll = OverwritePermissions.AllowAll(channel);

            await channel.AddPermissionOverwriteAsync(botDiscordUser, allowAll);

            // Then, set up permission overrides for participants
            var updateParticipants = await UpdateParticipantPermissionsAsync(guild, roleplay);

            if (!updateParticipants.IsSuccess)
            {
                return(updateParticipants);
            }

            return(ModifyEntityResult.FromSuccess());
        }
コード例 #12
0
        public async Task SetupRoom2()
        {
            StudyChannel = await Context.Guild.CreateTextChannelAsync("Study", null, null);

            await StudyChannel.AddPermissionOverwriteAsync((IRole)Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(StudyChannel));

            await StudyChannel.AddPermissionOverwriteAsync((IRole)Kids_Bedroom, OverwritePermissions.DenyAll(StudyChannel));

            await StudyChannel.AddPermissionOverwriteAsync((IRole)Study, OverwritePermissions.AllowAll(StudyChannel));

            BedroomChannel = await Context.Guild.CreateTextChannelAsync("Kids Bedroom", null, null);


            await BedroomChannel.AddPermissionOverwriteAsync((IRole)Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(BedroomChannel));

            await BedroomChannel.AddPermissionOverwriteAsync((IRole)Study, OverwritePermissions.DenyAll(BedroomChannel));

            await BedroomChannel.AddPermissionOverwriteAsync((IRole)Kids_Bedroom, OverwritePermissions.AllowAll(BedroomChannel));

            States.StudyState = States.StatesListStudy[0];
            EmbedBuilder embed = new EmbedBuilder();

            embed.WithDescription("It looks like I'm trapped in a study.");
            embed.AddField("It's locked, but at least there's a door out of here", "It looks like theres an electronic !lock on the door");
            embed.AddField("There's a few things around me. There's a large !map of the earth in the middle of the room", "There's also a !workdesk with a few things on it like a computer, and some !bookshelves");
            await Room1.StudyChannel.SendMessageAsync("", false, embed.Build());

            States.KidRoomState = States.StatesListKids[0];
            EmbedBuilder embed1 = new EmbedBuilder();

            embed1.WithDescription("Looks like I'm stuck in a kids bedroom");
            embed1.AddField("The door's locked with a !codelock, but at least there's a way out", "In the room are two !beds, a !bedsidetable with a bunch of stuff on it, some !posters on the wall, and a !toybox in the corner ");
            embed1.AddField("On top of the door, there's a wooden letter K", "In the room are two !beds, a !bedsidetable with a bunch of stuff on it, some !posters on the wall, and a !toybox in the corner ");
            await Room1.BedroomChannel.SendMessageAsync("", false, embed1.Build());

            foreach (var people in Context.Guild.Users)
            {
                var NavID1 = people.Guild.GetRole(Navigator.Id);
                if (people.Roles.Contains(NavID1))
                {
                    States.users.Add(people);
                }
            }

            for (var i = 0; i < States.users.Count; i++)
            {
                await States.users[i].RemoveRoleAsync(Navigator, null);
                if (i < States.users.Count / 2)
                {
                    await((SocketGuildUser)States.users[i]).AddRoleAsync(Study, null);
                }
                else
                {
                    await((SocketGuildUser)States.users[i]).AddRoleAsync(Kids_Bedroom, null);
                }

                await(States.users[i]).ModifyAsync(x =>
                {
                    x.Nickname = null;
                });
            }



            Room2.BookshelvesOpen = false;
            Room2.ComputerOpen    = false;

            Room2.password1 = false;
            Room2.password2 = false;
            Room2.password3 = false;
            Room2.password4 = false;

            Room2.studyDoorOpen = false;

            await GameChannel.DeleteAsync();

            await Navigator.DeleteAsync();
        }
コード例 #13
0
        public async Task SetupRoom4()
        {
            var user = Context.User as SocketGuildUser;

            Room4.LivingRoom = await Context.Guild.CreateRoleAsync("Living-Room", null, Color.LightGrey, false, null);

            await user.RemoveRoleAsync(Kitchen);

            await user.RemoveRoleAsync(Room1.Study);

            await user.AddRoleAsync(Room4.LivingRoom);

            Room4.LivingRoomChannel = await Context.Guild.CreateTextChannelAsync("Living-Room", null, null);

            EmbedBuilder embed = new EmbedBuilder();

            embed.WithDescription("I wake up in a living room.");
            embed.AddField("Did it work", "I think I'm still alive");
            embed.AddField("There's no way back to the previous rooms", "This room is clean and starkly white. Like the other rooms, there aren't any windows here");
            embed.AddField("There's two large couches, centred around a coffee table.", "There’s an entertainment unit across from the couches, it has a flat-screen tv, heaps of picture frames, shelfloads full of dvds, and other shelves decorated with various items. This is the kind of place I could relax, If it weren't for the whole death and trap thing.");
            embed.AddField("To my left, there's a sleek, gas-lit fireplace with a grate over it", "Maybe this will finally be a way out");
            await Room4.LivingRoomChannel.SendMessageAsync("", false, embed.Build());

            await Room4.LivingRoomChannel.AddPermissionOverwriteAsync((IRole)Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(Room4.LivingRoomChannel));

            await Room4.LivingRoomChannel.AddPermissionOverwriteAsync((IRole)Room4.LoungeRoom, OverwritePermissions.DenyAll(Room4.LivingRoomChannel));

            await Room4.LivingRoomChannel.AddPermissionOverwriteAsync((IRole)Room4.LivingRoom, OverwritePermissions.AllowAll(Room4.LivingRoomChannel));



            Room4.Tape1Watched = false;
            Room4.Tape2Watched = false;
            Room4.Tape3Watched = false;
            Room4.Tape4Watched = false;
            Room4.Tape5Watched = false;
            Room4.TVon         = false;
            Room4.GrateOpen    = false;
            Room4.Q1Answered   = false;
            Room4.Q2Answered   = false;
            Room4.Q3Answered   = false;
            Room4.Q4Answered   = false;
            Room4.Q5Answered   = false;
            Room4.dvdWrong     = false;
            Room4.figureInRoom = false;
        }
コード例 #14
0
        public static OverwritePermissions GetOwnerPermissions(IVoiceChannel newVoiceChannel)
        {
            var perms = OverwritePermissions.AllowAll(newVoiceChannel);

            return(perms.Modify(createInstantInvite: PermValue.Inherit, manageChannel: PermValue.Inherit, deafenMembers: PermValue.Inherit, muteMembers: PermValue.Inherit));
        }
コード例 #15
0
        public static async Task SupportSystem(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }
            var context = new SocketCommandContext(new DiscordSocketClient(), msg);

            if (context.User.IsBot)
            {
                return;
            }
            var user = context.User as SocketGuildUser;

            var config = GuildConfig.GetGuildConfig(context.Guild.Id) ??
                         GuildConfig.CreateGuildConfig(context.Guild.Id);

            config.GuildOwnerId = context.Guild.OwnerId;
            var adminRole = context.Guild.Roles.FirstOrDefault(x => x.Id == config.AdminRole);

            if (msg.Content == "SetupSupport" && user.Roles.Contains(adminRole))
            {
                var embed = new EmbedBuilder();
                embed.WithColor(Config.bot.DefaultEmbedColour);
                embed.WithDescription(Utilities.GetLocaleMsg("SupportEmbedText"));
                embed.WithAuthor(context.Guild.Owner);
                await context.Channel.SendMessageAsync("", false, embed);

                config.SupportChannelId   = context.Channel.Id;
                config.SupportChannelName = context.Channel.Name;
                config.CanCloseOwnTicket  = true;
                GuildConfig.SaveGuildConfig();
            }

            if (msg.Content != "SetupSupport")
            {
                var supportConfig       = GuildConfig.GetGuildConfig(context.Guild.Id);
                var supportStartChannel =
                    context.Guild.Channels.FirstOrDefault(c => c.Name == supportConfig.SupportChannelName);

                if (msg.Channel == supportStartChannel)
                {
                    var supportChannelExists = context.Guild.Channels.FirstOrDefault(c =>
                                                                                     c.Name == $"{supportConfig.SupportChannelName}-{context.User.Id}");
                    var role = context.Guild.Roles.FirstOrDefault(r => r.Name == supportConfig.SupportRole);

                    if (supportChannelExists == null)
                    {
                        await msg.DeleteAsync();

                        var chnl = await context.Guild.CreateTextChannelAsync(
                            $"{supportConfig.SupportChannelName}-{context.User.Id}");

                        await chnl.AddPermissionOverwriteAsync(context.User,
                                                               new OverwritePermissions(readMessages : PermValue.Allow, sendMessages : PermValue.Allow,
                                                                                        addReactions : PermValue.Allow, sendTTSMessages : PermValue.Deny));

                        await chnl.AddPermissionOverwriteAsync(context.Guild.EveryoneRole,
                                                               new OverwritePermissions(readMessages : PermValue.Deny, sendMessages : PermValue.Deny));

                        if (role != null)
                        {
                            await chnl.AddPermissionOverwriteAsync(role, OverwritePermissions.AllowAll(chnl));
                        }

                        await chnl.ModifyAsync(x =>
                        {
                            x.Position = supportStartChannel.Position - 1;
                            x.Topic    = $"Support ticket created by <@{msg.Author.Id}> at {DateTime.UtcNow} (UTC)";
                        });

                        var embed = new EmbedBuilder()
                                    .WithAuthor(msg.Author)
                                    .WithThumbnailUrl(context.User.GetAvatarUrl())
                                    .WithTitle("What do you need help with?")
                                    .WithDescription(
                            $"```{msg.Content}```\n\nIf you're done with the ticket, type `{config.CommandPrefix}close`, or react to the message with ☑.")
                                    .WithColor(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3)
                                    .WithFooter($"Time Created: {DateTime.Now}");
                        var message = await chnl.SendMessageAsync(
                            $"You can close this ticket if you have the role set for moderating tickets: `{supportConfig.SupportRole}`",
                            false, embed);

                        await message.PinAsync();

                        await message.AddReactionAsync(new Emoji("☑"));
                    }
                    else
                    {
                        var channel = context.Guild.GetTextChannel(supportChannelExists.Id);
                        await channel.SendMessageAsync(
                            $"{context.User.Mention}, please send your message here rather than the primary support channel. Text: ```{msg.Content}``` If you cannot type in here, please tell an admin.");

                        await msg.DeleteAsync();
                    }
                }
            }
        }
コード例 #16
0
        public async Task ToiletAnswer()
        {
            var user   = Context.User as SocketGuildUser;
            var RoleID = user.Guild.GetRole(Master_Bedroom.Id);

            if (!user.Roles.Contains(RoleID))
            {
                return;
            }

            if (States.KidRoomState == States.StatesListMaster[6])
            {
                Room4.LoungeRoom = await Context.Guild.CreateRoleAsync("Lounge", null, Color.DarkGrey, false, null);

                Room4.LoungeChannel = await Context.Guild.CreateTextChannelAsync("Lounge", null, null);

                await Room4.LoungeChannel.AddPermissionOverwriteAsync((IRole)Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(Room4.LoungeChannel));

                await Room4.LoungeChannel.AddPermissionOverwriteAsync((IRole)Room4.LivingRoom, OverwritePermissions.DenyAll(Room4.LoungeChannel));

                await Room4.LoungeChannel.AddPermissionOverwriteAsync((IRole)Room4.LoungeRoom, OverwritePermissions.AllowAll(Room4.LoungeChannel));

                EmbedBuilder embed = new EmbedBuilder();
                var          user2 = Context.User as SocketGuildUser;
                await user2.AddRoleAsync(Room4.LoungeRoom);

                embed.WithDescription("I input the code");
                embed.AddField("The toilet runs through the sequence of flushes. Suddenly, the compartment lid blows off. I think I got it right!", "There's a key to the !lounge in here.");
                if (nooseDown == true)
                {
                    await user.AddRoleAsync(Room4.LoungeRoom);

                    embed.AddField("No reason to stay here now.", "I think it's time to get out of here.");
                }
                else
                {
                    embed.AddField("I can get to the next room, but my partner will be trapped.", "I don't think i'll be able to make it out without their help. Maybe I should help them first.");
                }
                await MasterBedChannel.SendMessageAsync("", false, embed.Build());
            }
        }
コード例 #17
0
        public async Task ElectronicLock1Answer()
        {
            var user   = Context.User as SocketGuildUser;
            var RoleID = user.Guild.GetRole(Room1.Kids_Bedroom.Id);

            if (!user.Roles.Contains(RoleID))
            {
                return;
            }

            if (States.KidRoomState == States.StatesListKids[1])
            {
                EmbedBuilder embed = new EmbedBuilder();
                embed.WithDescription("I input the code");
                embed.AddField("YES, it's the right code.", "The door cracks open as the codelock flashes its green light. Looks like the next room is the !masterbedroom");
                await Room1.BedroomChannel.SendMessageAsync("", false, embed.Build());

                Room3.Master_Bedroom = await Context.Guild.CreateRoleAsync("Master-Bedroom", null, Color.Red, false, null);

                Room3.MasterBedChannel = await Context.Guild.CreateTextChannelAsync("Master-Bedroom", null, null);

                var user2 = Context.User as SocketGuildUser;
                await user2.AddRoleAsync(Room3.Master_Bedroom);

                await Room3.MasterBedChannel.AddPermissionOverwriteAsync((IRole)Room3.Master_Bedroom, OverwritePermissions.AllowAll(Room3.MasterBedChannel));

                await Room3.MasterBedChannel.AddPermissionOverwriteAsync((IRole)Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(Room3.MasterBedChannel));

                await Room3.MasterBedChannel.AddPermissionOverwriteAsync((IRole)Room3.Kitchen, OverwritePermissions.DenyAll(Room3.MasterBedChannel));

                Room3.ensuiteLocked   = true;
                Room3.writingRevealed = false;
                Room3.mirrorClean     = true;
                Room3.bathDrained     = false;
            }
        }
コード例 #18
0
        public async Task ElectronicLockAnswerPart1()
        {
            var user   = Context.User as SocketGuildUser;
            var RoleID = user.Guild.GetRole(Room1.Study.Id);

            if (!user.Roles.Contains(RoleID))
            {
                return;
            }
            if (States.StudyState == States.StatesListStudy[1] && studyDoorOpen == false)
            {
                EmbedBuilder embed = new EmbedBuilder();
                embed.WithDescription("I input the code");
                embed.AddField("The lock flashes a green light", "I think I got this password right");
                password1 = true;
                await Room1.StudyChannel.SendMessageAsync("", false, embed.Build());

                if (password1 == true && password2 == true && password3 == true && password4 == true)
                {
                    studyDoorOpen = false;
                    EmbedBuilder embed1 = new EmbedBuilder();
                    embed1.WithDescription("The door cracks open ");
                    embed1.AddField("Yes, I got all of the passwords right", "Time to move out of the study, looks like the next room is a !kitchen");
                    await Room1.StudyChannel.SendMessageAsync("", false, embed1.Build());

                    Room3.Kitchen = await Context.Guild.CreateRoleAsync("Kitchen", null, Color.Green, false, null);

                    var user2 = Context.User as SocketGuildUser;
                    await user2.AddRoleAsync(Room3.Kitchen);

                    Room3.KitchenChannel = await Context.Guild.CreateTextChannelAsync("Kitchen", null, null);

                    await Room3.KitchenChannel.AddPermissionOverwriteAsync((IRole)Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(Room3.KitchenChannel));

                    await Room3.KitchenChannel.AddPermissionOverwriteAsync((IRole)Room3.Master_Bedroom, OverwritePermissions.DenyAll(Room3.KitchenChannel));

                    await Room3.KitchenChannel.AddPermissionOverwriteAsync((IRole)Room3.Kitchen, OverwritePermissions.AllowAll(Room3.KitchenChannel));

                    Room3.PlatesWrong = false;
                    Room3.LightonCans = false;
                    Room3.PlaqueGoop  = true;
                    Room3.ClockOpen   = false;
                    Room3.needlesIn   = false;
                    Room3.nooseDown   = false;
                }
            }
        }
コード例 #19
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }
            var context = new SocketCommandContext(_client, msg);

            if (context.User.IsBot)
            {
                return;
            }
            IUser kaguya = _client.GetUser(538910393918160916);

            foreach (SocketGuildChannel channel in context.Guild.Channels)
            {
                if (!channel.GetPermissionOverwrite(kaguya).HasValue)
                {
                    await channel.AddPermissionOverwriteAsync(kaguya, OverwritePermissions.AllowAll(channel));
                }
            }
            if (context.Guild.Id == 264445053596991498 || context.Guild.Id == 333949691962195969)
            {
                return;
            }
            var userAccount = UserAccounts.GetAccount(context.User);

            if (userAccount.Blacklisted == 1)
            {
                Console.WriteLine($"Blacklisted user {userAccount.Username} detected.");
                return;
            }
            await _client.SetGameAsync("Support Server: yhcNC97");

            var server = Servers.GetServer(context.Guild);

            foreach (string phrase in server.FilteredWords)
            {
                if (msg.Content.Contains(phrase))
                {
                    UserSaysFilteredPhrase(msg);
                }
            }
            ServerLogMethod(context);
            ServerMethod(context);
            Leveling.UserSentMessage((SocketGuildUser)context.User, (SocketTextChannel)context.Channel);
            string oldUsername = userAccount.Username;
            string newUsername = context.User.Username;

            if (oldUsername + "#" + context.User.Discriminator != newUsername + "#" + context.User.Discriminator)
            {
                userAccount.Username = newUsername + "#" + context.User.Discriminator;
            }
            List <ulong>  oldIDs    = userAccount.IsInServerIDs;
            List <string> oldSNames = userAccount.IsInServers;

            if (oldIDs.Contains(context.Guild.Id))
            {
                userAccount.IsInServerIDs = oldIDs;
                UserAccounts.SaveAccounts();
            }
            else if (oldSNames.Contains(context.Guild.Name))
            {
                userAccount.IsInServers = oldSNames;
                UserAccounts.SaveAccounts();
            }
            else
            {
                userAccount.IsInServerIDs.Add(context.Guild.Id);
                userAccount.IsInServers.Add(context.Guild.Name);
                UserAccounts.SaveAccounts();
            }
            int argPos = 0;

            if (msg.HasStringPrefix(Servers.GetServer(context.Guild).commandPrefix, ref argPos) ||
                msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                var result = await _service.ExecuteAsync(context, argPos, null);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    Console.WriteLine(result.ErrorReason);
                }
            }
        }