Exemplo n.º 1
0
        public async Task StartMainSync()
        {
            //Init
            if (Config.bot.token != "" && Config.bot.token != null)
            {
                Console.WriteLine(String.Format("----<>---- DiscordButlerBot Ver: {0}.{1}.{2} ----<>----", versionMajor, versionMinor, versionPatch));
                Console.WriteLine("Made By: Lejara");
                //Init REST socket
                client_ = new DiscordSocketClient(new DiscordSocketConfig {
                    LogLevel = LogSeverity.Verbose
                });
                client_.Log            += Client_Logging;
                client_.GuildAvailable += InitJoinedGuild;
                client_.JoinedGuild    += InitJoinedGuild;

                //Init Func Helper
                FuncHelpers.Init();

                // Login/Start
                await client_.LoginAsync(TokenType.Bot, Config.bot.token);

                await client_.StartAsync();

                //Init Command Handler
                handler_ = new CommandHandler();
                await handler_.InitAsyncTask(client_);

                await Task.Delay(-1);
            }
            return;
        }
Exemplo n.º 2
0
        public async Task ClearVCTopic()
        {
            var    callingUser        = Context.User as IGuildUser;
            var    voiceChannelUserIn = callingUser.VoiceChannel;
            string vcName             = voiceChannelUserIn.Name;

            if (voiceChannelUserIn != null)
            {
                if (FuncHelpers.RemoveTopicBracket(ref vcName))
                {
                    if (Config.serverData[callingUser.GuildId].removeFirstWord_)
                    {
                        vcName = String.Format("{0}{1}", Config.serverData[callingUser.GuildId].firstWordTitle_, vcName);
                        Config.serverData[callingUser.GuildId].firstWordTitle_ = "";
                    }

                    await callingUser.VoiceChannel.ModifyAsync(x =>
                    {
                        x.Name = vcName;
                    });

                    await Context.Channel.SendMessageAsync(String.Format("Master {0}, topic was removed in {1}", callingUser.Mention, vcName));
                }
                else
                {
                    await Context.Channel.SendMessageAsync("Master, no topic was set in " + vcName);
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync(String.Format("Master {0}, you need to be in a voice channel to clear a topic", callingUser.Mention));
            }
        }
Exemplo n.º 3
0
        public async Task ListVoice()
        {
            var guildUser          = Context.User as SocketGuildUser;
            var voiceChannelUserIn = guildUser.VoiceChannel;

            if (guildUser.VoiceChannel != null)
            {
                string listingReplyMsg = "";

                var    users  = voiceChannelUserIn.Users;
                string vcName = voiceChannelUserIn.Name;
                FuncHelpers.RemoveTopicBracket(ref vcName);
                EmbedBuilder em = new EmbedBuilder();
                em.WithTitle("Members in Voice " + vcName);
                em.WithColor(new Color(10, 10, 10));
                em.WithFooter("");
                foreach (var user in users)
                {
                    listingReplyMsg += "-" + user.Mention;
                    listingReplyMsg += "\n";
                }
                em.WithDescription(listingReplyMsg);
                await Context.Channel.SendMessageAsync("Master " + guildUser.Mention + ", here is your list: \n", false, em.Build());
            }
            else
            {
                await Context.Channel.SendMessageAsync(String.Format("Sorry master {0}, you need to be in a voice channel to use this command.", Context.User.Mention));
            }
        }
Exemplo n.º 4
0
        public async Task SetVCTopic([Remainder] string newTopic = "")
        {
            var guildUser          = Context.User as IGuildUser;
            var voiceChannelUserIn = guildUser.VoiceChannel;

            if (voiceChannelUserIn != null)
            {
                if (newTopic != null && newTopic != "")
                {
                    if (newTopic.Length <= Config.serverData[guildUser.GuildId].maxTopicNameLength_)
                    {
                        string vcName;

                        //remove first word if true
                        if (Config.serverData[guildUser.GuildId].removeFirstWord_ && Config.serverData[guildUser.GuildId].firstWordTitle_ == "")
                        {
                            vcName = RemoveChannelNameFirstWord(voiceChannelUserIn.Name, guildUser.GuildId);
                        }
                        else
                        {
                            vcName = voiceChannelUserIn.Name;
                        }

                        string vcNameNoTopic = FuncHelpers.RemoveTopicBracket(ref vcName) == false ? voiceChannelUserIn.Name : vcName;

                        vcName += String.Format(" ({0})", newTopic);
                        await guildUser.VoiceChannel.ModifyAsync(x =>
                        {
                            x.Name = vcName;
                        });

                        FuncHelpers.AddTopicTracking(new VCTopicData(DateTime.Now, voiceChannelUserIn));

                        await Context.Channel.SendMessageAsync(String.Format("Master {0}, the topic is now set to \"{1}\" in {2}",
                                                                             guildUser.Mention, newTopic, String.Format("{0}{1}", Config.serverData[guildUser.GuildId].firstWordTitle_, vcNameNoTopic)));
                    }
                    else
                    {
                        await Context.Channel.SendMessageAsync(String.Format("Sorry master {0}, the topic name is too long it needs to be less than {1} characters.", guildUser.Mention, Config.serverData[guildUser.GuildId].maxTopicNameLength_));
                    }
                }
                else
                {
                    await ClearVCTopic();
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync(String.Format("Master {0}, you need to be in a voice channel to set a topic!", guildUser.Mention));
            }
        }
Exemplo n.º 5
0
        public void FourtyTwoReturnsFalse()
        {
            var result = FuncHelpers.ReturnFalse(42);

            Assert.False(result);
        }
Exemplo n.º 6
0
        public void SelectSelfWorksWithInt()
        {
            var result = FuncHelpers.SelectSelf(42);

            Assert.Equal(42, result);
        }
Exemplo n.º 7
0
        public void SelectSelfWorksWithNullString()
        {
            var result = FuncHelpers.SelectSelf <string>(null);

            Assert.Null(result);
        }
Exemplo n.º 8
0
        public void SelectSelfWorksWithString()
        {
            var result = FuncHelpers.SelectSelf("Hello World");

            Assert.Equal("Hello World", result);
        }
Exemplo n.º 9
0
        public void StringReturnsFalse()
        {
            var result = FuncHelpers.ReturnFalse("Hello World");

            Assert.False(result);
        }
Exemplo n.º 10
0
        public void NullStringReturnsFalse()
        {
            var result = FuncHelpers.ReturnFalse <string>(null);

            Assert.False(result);
        }