Ejemplo n.º 1
0
        public static async Task <bool> JoinChannel(string server, string channel)
        {
            SocketVoiceChannel chan = null;

            foreach (SocketVoiceChannel vchannel in GetSocketChannels(server))
            {
                if (vchannel.Name == channel)
                {
                    chan = vchannel;
                }
            }

            if (chan != null)
            {
                try
                {
                    audioClient = await chan.ConnectAsync();

                    Log?.Invoke("Joined channel: " + chan.Name);
                }
                catch (Exception e)
                {
                    Log(e.Message);
                    return(false);
                }
            }
            await bot.SetGameAsync("with ACT Triggers");

            return(true);
        }
Ejemplo n.º 2
0
        public void Fire(BaseRtmResponse response)
        {
            AllMessages?.Invoke(this, new RtmMessageEventArgs <BaseRtmResponse>(response));

            switch (response)
            {
            case HelloResponse helloResponse:
                HelloMessage?.Invoke(this, new RtmMessageEventArgs <HelloResponse>(helloResponse));
                break;

            case PongResponse pongResponse:
                PongMessage?.Invoke(this, new RtmMessageEventArgs <PongResponse>(pongResponse));
                break;

            case UserTypingResponse userTypingResponse:
                UserTypingMessage?.Invoke(this, new RtmMessageEventArgs <UserTypingResponse>(userTypingResponse));
                break;

            case BaseMessageResponse messageResponse:
                switch (messageResponse)
                {
                case BotMessageResponse botMessageResponse:
                    BotMessage?.Invoke(this, new RtmMessageEventArgs <BotMessageResponse>(botMessageResponse));
                    break;

                default:
                    UserMessage?.Invoke(this, new RtmMessageEventArgs <UserMessageResponse>(messageResponse));
                    break;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 3
0
        public static async void InIt(string logintoken)
        {
            try {
                bot = new DiscordSocketClient();
            } catch (NotSupportedException ex) {
                Log?.Invoke("Unsupported Operating System.");
                Log?.Invoke(ex.Message);
            }

            try {
                bot.Log   += Bot_Log;
                bot.Ready += Bot_Ready;
                await bot.LoginAsync(TokenType.Bot, logintoken);

                await bot.StartAsync();
            } catch (Exception ex) {
                Log?.Invoke(ex.Message);
                Log?.Invoke("Error connecting to Discord.");
            }
        }