Esempio n. 1
0
        //------------------------------------------------------------------------
        public async Task RunStreamRemove(ulong msgid)
        {
            DiscordBotUserToken         token = new DiscordBotUserToken(ProgHelpers.bottoken); //token
            DiscordWebSocketApplication app   = new DiscordWebSocketApplication(token);
            Shard shard = app.ShardManager.CreateSingleShard();
            await shard.StartAsync(CancellationToken.None);

            Snowflake xx   = new Snowflake();
            ulong     xxid = (ulong)Convert.ToInt64(ProgHelpers.channelid);

            xx.Id = xxid;
            //ITextChannel textChannel = (ITextChannel)shard.Cache.Channels.Get(xx);
            //ITextChannel textChannel = (ITextChannel)shard.Application.HttpApi.Channels.Get(xx);

            try
            {
                //Edit msg test
                Snowflake editflake = new Snowflake();
                ulong     xxedit    = (ulong)Convert.ToInt64(msgid);
                editflake.Id = msgid;
                await app.HttpApi.Channels.DeleteMessage(xx, editflake);

                Console.WriteLine("Removing row complete");
            }
            catch (Exception ex)
            {
                Console.WriteLine("! EX: An error while removing the announcement! Details as follows:");
                Console.WriteLine(ex);
            }

            await shard.StopAsync();

            //returning
            return;
        }
Esempio n. 2
0
        public async Task Run()
        {
            DiscordBotUserToken token = new DiscordBotUserToken("<bot user token goes here>");

            DiscordWebSocketApplication app = new DiscordWebSocketApplication(token);

            shard.Gateway.OnMessageCreated += Gateway_OnMessageCreated;
        }
Esempio n. 3
0
        //-------------------------------------------------------------------------
        public async Task <int> RunStreamAnnounce(string url, string title, string name, int viewers, string timestamp, string avatarurl, string game)
        {
            DiscordBotUserToken         token = new DiscordBotUserToken(ProgHelpers.bottoken); //token
            DiscordWebSocketApplication app   = new DiscordWebSocketApplication(token);
            Shard shard = app.ShardManager.CreateSingleShard();
            await shard.StartAsync(CancellationToken.None);

            Snowflake xx   = new Snowflake();
            ulong     xxid = (ulong)Convert.ToInt64(ProgHelpers.channelid);

            xx.Id = xxid;
            //ITextChannel textChannel = (ITextChannel)shard.Cache.Channels.Get(xx);
            //ITextChannel textChannel = (ITextChannel)shard.Application.HttpApi.Channels.Get(xx);

            try
            {
                //Announcing stream
                DiscordMessage annch = await app.HttpApi.Channels.CreateMessage(xx, new DiscordMessageDetails()
                                                                                .SetEmbed(new DiscordEmbedBuilder()
                                                                                          .SetTitle(name)
                                                                                          .SetFooter("kitsun8's Sniperiino, " + ProgHelpers.version)
                                                                                          .SetColor(DiscordColor.FromHexadecimal(0xff9933))
                                                                                          .SetUrl(url)
                                                                                          .SetThumbnail(avatarurl)
                                                                                          .AddField(ProgHelpers.txtstreamtitle, title, false)
                                                                                          .AddField(":busts_in_silhouette: " + ProgHelpers.txtviewers + " ", viewers.ToString(), true)
                                                                                          .AddField(":game_die: " + ProgHelpers.txtgame + " ", game, true)
                                                                                          .AddField(":clock10: " + ProgHelpers.txtstartedtime + " ", timestamp, false)
                                                                                          ));

                //01/07
                var announceid = annch.Id;
                if (announceid != null)
                {
                    ProgHelpers.alreadyannouncedmessageids.Add(announceid.Id);
                }


                await shard.StopAsync();

                //returning
                return(1);
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex);
                Console.WriteLine("! EX: Ran into exception while announcing a stream! Details as follows:");
                Console.WriteLine(ex);
                await shard.StopAsync();

                return(0);
            }
        }
Esempio n. 4
0
        //-------------------------------------------------------------------------
        public async Task RunStreamEdit(string url, string title, string name, int viewers, string timestamp, string avatarurl, string game, ulong msgid)
        {
            DiscordBotUserToken         token = new DiscordBotUserToken(ProgHelpers.bottoken); //token
            DiscordWebSocketApplication app   = new DiscordWebSocketApplication(token);
            Shard shard = app.ShardManager.CreateSingleShard();
            await shard.StartAsync(CancellationToken.None);

            Snowflake xx   = new Snowflake();
            ulong     xxid = (ulong)Convert.ToInt64(ProgHelpers.channelid);

            xx.Id = xxid;
            //ITextChannel textChannel = (ITextChannel)shard.Cache.Channels.Get(xx);
            //ITextChannel textChannel = (ITextChannel)shard.Application.HttpApi.Channels.Get(xx);

            try
            {
                //Edit msg test
                Snowflake editflake = new Snowflake();
                ulong     xxedit    = (ulong)Convert.ToInt64(msgid);
                editflake.Id = msgid;
                DiscordMessage annEdit = await app.HttpApi.Channels.EditMessage(xx, editflake, new DiscordMessageEdit()
                                                                                .SetEmbed(new DiscordEmbedBuilder()
                                                                                          .SetTitle(name)
                                                                                          .SetFooter("kitsun8's Sniperiino, " + ProgHelpers.version)
                                                                                          .SetColor(DiscordColor.FromHexadecimal(0xff9933))
                                                                                          .SetUrl(url)
                                                                                          .SetThumbnail(avatarurl)
                                                                                          .AddField(ProgHelpers.txtstreamtitle, title, false)
                                                                                          .AddField(":busts_in_silhouette: " + ProgHelpers.txtviewers + " ", viewers.ToString(), true)
                                                                                          .AddField(":game_die: " + ProgHelpers.txtgame + " ", game, true)
                                                                                          .AddField(":clock10: " + ProgHelpers.txtstartedtime + " ", timestamp, false)
                                                                                          ));

                Console.WriteLine("! Editing row complete");

                await shard.StopAsync();

                //returning
                return;
            }
            catch (Exception ex)
            {
                Console.WriteLine("! EX: An error while editing the announce! Details as follows:");
                Console.WriteLine(ex);
                await shard.StopAsync();

                return;
            }
        }
Esempio n. 5
0
        //-------------------------------------------------------------------------
        public async Task Run()
        {
            // Create authenticator using a bot user token.
            DiscordBotUserToken token = new DiscordBotUserToken(ProgHelpers.bottoken); //token
            // Create a WebSocket application.
            DiscordWebSocketApplication app = new DiscordWebSocketApplication(token);
            // Create and start a single shard.
            Shard shard = app.ShardManager.CreateSingleShard();
            await shard.StartAsync(CancellationToken.None);

            // Subscribe to the message creation event.
            shard.Gateway.OnMessageCreated += Gateway_OnMessageCreated;

            Console.WriteLine("# Timer started");
            Program.StartTimer();

            // Wait for the shard to end before closing the program.
            while (shard.IsRunning)
            {
                await Task.Delay(1000);
            }
        }
Esempio n. 6
0
        public async Task Run()
        {
            // Create authenticator using a bot user token.
            DiscordBotUserToken token = new DiscordBotUserToken(Settings.Bot_Token);

            // Create a WebSocket application.
            DiscordWebSocketApplication app = new DiscordWebSocketApplication(token);

            // Create and start a single shard.
            Shard shard = app.ShardManager.CreateSingleShard();
            await shard.StartAsync();

            // Subscribe to the message creation event.
            shard.Gateway.OnMessageCreated += Gateway_OnMessageCreated;

            await Setup(shard);

            // Wait for the shard to end before closing the program.
            while (shard.IsRunning)
            {
                await Task.Delay(1000);
            }
        }
Esempio n. 7
0
        public static async Task Start()
        {
            Settings.Load();
            Log.Taexify();

            DiscordBotUserToken         token = new DiscordBotUserToken(Settings.Sunbae.Token);
            DiscordWebSocketApplication app   = new DiscordWebSocketApplication(token);

            Shard shard = app.ShardManager.CreateSingleShard();
            await shard.StartAsync(CancellationToken.None);

            shard.Gateway.OnMessageCreated += CommandParser.ProcessCommand;
            shard.Gateway.OnMessageCreated += ProcessMessage;

            CommandParser.SetPrefix(".");

            // Commands
            CommandFactory.RegisterCommand("ping", new PingCommand());

            while (shard.IsRunning)
            {
                await Task.Delay(1000);
            }
        }