From 0b5c627ecaad3c2c88237ab23ad66d374d850c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 04:59:05 +0100 Subject: [PATCH 01/14] Changed enviroment keys --- Bot_Discord_CSharp/Bot.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bot_Discord_CSharp/Bot.cs b/Bot_Discord_CSharp/Bot.cs index 5557e1d..f66f183 100644 --- a/Bot_Discord_CSharp/Bot.cs +++ b/Bot_Discord_CSharp/Bot.cs @@ -24,7 +24,7 @@ namespace Bot_Discord_CSharp public async Task RunAsync() { string token, prefix; - if (!Environment.GetEnvironmentVariables().Contains("Token")) + if (!Environment.GetEnvironmentVariables().Contains("TOKEN")) { var json = string.Empty; @@ -38,8 +38,8 @@ namespace Bot_Discord_CSharp } else { - token = Environment.GetEnvironmentVariable("Token"); - prefix = Environment.GetEnvironmentVariable("Prefix"); + token = Environment.GetEnvironmentVariable("TOKEN"); + prefix = Environment.GetEnvironmentVariable("PREFIX"); } var config = new DiscordConfiguration From 33e7687ad00a99089c4807915241201bf32fd93c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 05:52:19 +0100 Subject: [PATCH 02/14] Send message when startup --- Bot_Discord_CSharp/Bot.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Bot_Discord_CSharp/Bot.cs b/Bot_Discord_CSharp/Bot.cs index f66f183..605aa32 100644 --- a/Bot_Discord_CSharp/Bot.cs +++ b/Bot_Discord_CSharp/Bot.cs @@ -12,6 +12,7 @@ using Bot_Discord_CSharp.Commands; using Microsoft.Extensions.Logging; using DSharpPlus.Interactivity; using DSharpPlus.Interactivity.Extensions; +using DSharpPlus.Entities; namespace Bot_Discord_CSharp { @@ -76,9 +77,11 @@ namespace Bot_Discord_CSharp await Task.Delay(-1); } - private Task OnClientReady(DiscordClient client, ReadyEventArgs e) + private async Task OnClientReady(DiscordClient client, ReadyEventArgs e) { - return null; + DiscordGuild guild = await client.GetGuildAsync(732743391548407888, true); + DiscordChannel channel = guild.GetChannel(785719482924007424); + await channel.SendMessageAsync("Ya estoy de vuelta"); } private void RegisterCommands() From 2ea67a678ed4c22e30bad7c8af27a45702798c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 06:03:52 +0100 Subject: [PATCH 03/14] Actualiced commands --- Bot_Discord_CSharp/Commands/TestCommand.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Bot_Discord_CSharp/Commands/TestCommand.cs b/Bot_Discord_CSharp/Commands/TestCommand.cs index 4427c43..cab575b 100644 --- a/Bot_Discord_CSharp/Commands/TestCommand.cs +++ b/Bot_Discord_CSharp/Commands/TestCommand.cs @@ -27,6 +27,7 @@ namespace Bot_Discord_CSharp.Commands } [Command("response")] + [Hidden] public async Task Response(CommandContext ctx) { var interactivity = ctx.Client.GetInteractivity(); @@ -39,6 +40,7 @@ namespace Bot_Discord_CSharp.Commands } [Command("respondReaction")] + [Hidden] public async Task ResponseReaction(CommandContext ctx) { var interactivity = ctx.Client.GetInteractivity(); @@ -86,15 +88,20 @@ namespace Bot_Discord_CSharp.Commands } [Command("fecha")] + [Description("Te devuelve la fecha de hoy")] public async Task GetCurrentDay(CommandContext ctx) { await ctx.Channel.SendMessageAsync(Today()); } [Command("borrar")] - public async Task DeleteAllMessages(CommandContext ctx) + [Description("Borra los últimos X mensajes o si no se pone nada los últimos 100")] + public async Task DeleteAllMessages(CommandContext ctx, params string[] command) { - IReadOnlyCollection messages = await ctx.Channel.GetMessagesAsync(100); + int numberOfMenssages; + if (!command.Any()) numberOfMenssages = 100; + else numberOfMenssages = Int32.Parse(command[0]); + IReadOnlyCollection messages = await ctx.Channel.GetMessagesAsync(numberOfMenssages); await ctx.Channel.DeleteMessagesAsync(messages); } From a9c36ffe713e503b412c6f501bcda4af2d1352d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 12:31:24 +0100 Subject: [PATCH 04/14] Hotfix for heroku deployment --- Bot_Discord_CSharp/Bot_Discord_CSharp.csproj | 3 +++ Bot_Discord_CSharp/Program.cs | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj b/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj index 18b83b2..577d7d6 100644 --- a/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj +++ b/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj @@ -6,10 +6,13 @@ + + + diff --git a/Bot_Discord_CSharp/Program.cs b/Bot_Discord_CSharp/Program.cs index 6318961..4d61081 100644 --- a/Bot_Discord_CSharp/Program.cs +++ b/Bot_Discord_CSharp/Program.cs @@ -1,4 +1,7 @@ -using System; +using Cqrs.Hosts; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using System; namespace Bot_Discord_CSharp { @@ -6,8 +9,18 @@ namespace Bot_Discord_CSharp { static void Main(string[] args) { + var host = CreateWebHostBuilder(args). + UseKestrel(). + UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("$PORT")). + Build(); + + host.Run(); + Bot bot = new Bot(); bot.RunAsync().GetAwaiter().GetResult(); } + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); } } From 508f26a33a28a546bf08bc269e9ff05bf9aca318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 13:01:31 +0100 Subject: [PATCH 05/14] Hotfix port --- Bot_Discord_CSharp/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bot_Discord_CSharp/Program.cs b/Bot_Discord_CSharp/Program.cs index 4d61081..530778f 100644 --- a/Bot_Discord_CSharp/Program.cs +++ b/Bot_Discord_CSharp/Program.cs @@ -11,7 +11,7 @@ namespace Bot_Discord_CSharp { var host = CreateWebHostBuilder(args). UseKestrel(). - UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("$PORT")). + UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("PORT")). Build(); host.Run(); From d88c07ccdf4c8804cf0f40ee02cb800133f4987a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 13:04:24 +0100 Subject: [PATCH 06/14] Changed library of ports --- Bot_Discord_CSharp/Bot_Discord_CSharp.csproj | 2 +- Bot_Discord_CSharp/Program.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj b/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj index 577d7d6..0f5ca3f 100644 --- a/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj +++ b/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj @@ -6,11 +6,11 @@ - + diff --git a/Bot_Discord_CSharp/Program.cs b/Bot_Discord_CSharp/Program.cs index 530778f..a070efa 100644 --- a/Bot_Discord_CSharp/Program.cs +++ b/Bot_Discord_CSharp/Program.cs @@ -1,4 +1,5 @@ using Cqrs.Hosts; +using ikvm.runtime; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using System; @@ -11,7 +12,7 @@ namespace Bot_Discord_CSharp { var host = CreateWebHostBuilder(args). UseKestrel(). - UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("PORT")). + UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("$PORT")). Build(); host.Run(); @@ -21,6 +22,6 @@ namespace Bot_Discord_CSharp } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup(); + .UseStartup(); } } From cb5eba8d9af4729e0a9e3c0897ea919fea86c748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 13:04:51 +0100 Subject: [PATCH 07/14] Deleted using not necesary --- Bot_Discord_CSharp/Program.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Bot_Discord_CSharp/Program.cs b/Bot_Discord_CSharp/Program.cs index a070efa..abcee1d 100644 --- a/Bot_Discord_CSharp/Program.cs +++ b/Bot_Discord_CSharp/Program.cs @@ -1,5 +1,4 @@ -using Cqrs.Hosts; -using ikvm.runtime; +using ikvm.runtime; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using System; From ecb57a240b3b994bfcea9ee7cd23f5e7535969b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 13:27:34 +0100 Subject: [PATCH 08/14] Hotfix, again... --- Bot_Discord_CSharp/Program.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Bot_Discord_CSharp/Program.cs b/Bot_Discord_CSharp/Program.cs index abcee1d..845b8c1 100644 --- a/Bot_Discord_CSharp/Program.cs +++ b/Bot_Discord_CSharp/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using System; +using System.IO; namespace Bot_Discord_CSharp { @@ -9,18 +10,18 @@ namespace Bot_Discord_CSharp { static void Main(string[] args) { - var host = CreateWebHostBuilder(args). - UseKestrel(). - UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("$PORT")). - Build(); + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("$PORT")) + .Build(); host.Run(); Bot bot = new Bot(); bot.RunAsync().GetAwaiter().GetResult(); } - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup(); } } From 3feb5243e0a9ae85db437199c6b374bb0d089e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 20:42:25 +0100 Subject: [PATCH 09/14] Delete port --- Bot_Discord_CSharp/Bot_Discord_CSharp.csproj | 1 - Bot_Discord_CSharp/Program.cs | 14 +------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj b/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj index 0f5ca3f..e0d6185 100644 --- a/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj +++ b/Bot_Discord_CSharp/Bot_Discord_CSharp.csproj @@ -10,7 +10,6 @@ - diff --git a/Bot_Discord_CSharp/Program.cs b/Bot_Discord_CSharp/Program.cs index 845b8c1..f2b65ca 100644 --- a/Bot_Discord_CSharp/Program.cs +++ b/Bot_Discord_CSharp/Program.cs @@ -1,6 +1,4 @@ -using ikvm.runtime; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting; using System; using System.IO; @@ -10,16 +8,6 @@ namespace Bot_Discord_CSharp { static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .UseUrls("http://0.0.0.0:" + Environment.GetEnvironmentVariable("$PORT")) - .Build(); - - host.Run(); - Bot bot = new Bot(); bot.RunAsync().GetAwaiter().GetResult(); } From d85919173e30aa60d46ee5667eece249d8472454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 21:10:53 +0100 Subject: [PATCH 10/14] Created Procfile --- Bot_Discord_CSharp/Procfile.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 Bot_Discord_CSharp/Procfile.txt diff --git a/Bot_Discord_CSharp/Procfile.txt b/Bot_Discord_CSharp/Procfile.txt new file mode 100644 index 0000000..7b8024a --- /dev/null +++ b/Bot_Discord_CSharp/Procfile.txt @@ -0,0 +1 @@ +worker: dotnet run discord-bot-dsharp \ No newline at end of file From 0f4027390db1eaf10a614ab128b8b94667185f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20G=C3=B3mez=20Cuenca?= Date: Tue, 8 Dec 2020 21:15:31 +0100 Subject: [PATCH 11/14] Deleted Procfile --- Bot_Discord_CSharp/Procfile.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Bot_Discord_CSharp/Procfile.txt diff --git a/Bot_Discord_CSharp/Procfile.txt b/Bot_Discord_CSharp/Procfile.txt deleted file mode 100644 index 7b8024a..0000000 --- a/Bot_Discord_CSharp/Procfile.txt +++ /dev/null @@ -1 +0,0 @@ -worker: dotnet run discord-bot-dsharp \ No newline at end of file From 967ec2196d49863373f901756cc252283d88a717 Mon Sep 17 00:00:00 2001 From: alvaron14 <42387666+alvaron14@users.noreply.github.com> Date: Tue, 8 Dec 2020 21:16:12 +0100 Subject: [PATCH 12/14] Create Procfile --- Procfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..65ee930 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +worker: dotnet run discord-bot-dsharp From 75ebecf44555ec4517518aaba223a4534d509764 Mon Sep 17 00:00:00 2001 From: alvaron14 <42387666+alvaron14@users.noreply.github.com> Date: Tue, 8 Dec 2020 21:22:58 +0100 Subject: [PATCH 13/14] Update Procfile --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 65ee930..39028c9 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: dotnet run discord-bot-dsharp +worker: cd $HOME/heroku_output && ./Bot_Discord_CSharp From 0d6fe91bf7f55fbf9e13d07d4dfc3d6dc81e57cc Mon Sep 17 00:00:00 2001 From: alvaron14 <42387666+alvaron14@users.noreply.github.com> Date: Tue, 8 Dec 2020 21:35:08 +0100 Subject: [PATCH 14/14] Update Procfile --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 39028c9..cb93b52 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: cd $HOME/heroku_output && ./Bot_Discord_CSharp +worker: node Bot_Discord_CSharp