diff --git a/BUILDS/net6.0/PluginManager.dll b/BUILDS/net6.0/PluginManager.dll index 97cc813..d7791de 100644 Binary files a/BUILDS/net6.0/PluginManager.dll and b/BUILDS/net6.0/PluginManager.dll differ diff --git a/BUILDS/net6.0/StartupEvents.dll b/BUILDS/net6.0/StartupEvents.dll index e52d403..916b19a 100644 Binary files a/BUILDS/net6.0/StartupEvents.dll and b/BUILDS/net6.0/StartupEvents.dll differ diff --git a/DiscordBot.sln b/DiscordBot.sln index 0960e41..2b04d0b 100644 --- a/DiscordBot.sln +++ b/DiscordBot.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31729.503 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32421.90 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordBot", "DiscordBot\DiscordBot.csproj", "{087E64F4-1E1C-4899-8223-295356C9894A}" EndProject @@ -23,6 +23,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMD_Utils", "CMD_Utils\CMD_ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicCommands", "MusicCommands\MusicCommands.csproj", "{B1B4976E-5112-4217-B57B-3A03C5207B6E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Holiday events", "Holiday events\Holiday events.csproj", "{108BD621-EC08-4AC4-86D2-79B429562A90}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "New User", "New User\New User.csproj", "{02217691-EF7E-4FB2-91FC-C6EF07BF6094}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -57,6 +61,14 @@ Global {B1B4976E-5112-4217-B57B-3A03C5207B6E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B1B4976E-5112-4217-B57B-3A03C5207B6E}.Release|Any CPU.ActiveCfg = Release|Any CPU {B1B4976E-5112-4217-B57B-3A03C5207B6E}.Release|Any CPU.Build.0 = Release|Any CPU + {108BD621-EC08-4AC4-86D2-79B429562A90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {108BD621-EC08-4AC4-86D2-79B429562A90}.Debug|Any CPU.Build.0 = Debug|Any CPU + {108BD621-EC08-4AC4-86D2-79B429562A90}.Release|Any CPU.ActiveCfg = Release|Any CPU + {108BD621-EC08-4AC4-86D2-79B429562A90}.Release|Any CPU.Build.0 = Release|Any CPU + {02217691-EF7E-4FB2-91FC-C6EF07BF6094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02217691-EF7E-4FB2-91FC-C6EF07BF6094}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02217691-EF7E-4FB2-91FC-C6EF07BF6094}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02217691-EF7E-4FB2-91FC-C6EF07BF6094}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -69,6 +81,8 @@ Global {CE9DBF06-38A0-4192-8B3E-4009210D040D} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012} {E26C87A4-3DD6-4B58-B14B-C8E086B852F9} = {449FA364-0B72-43FF-B3A3-806E2916200E} {B1B4976E-5112-4217-B57B-3A03C5207B6E} = {449FA364-0B72-43FF-B3A3-806E2916200E} + {108BD621-EC08-4AC4-86D2-79B429562A90} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012} + {02217691-EF7E-4FB2-91FC-C6EF07BF6094} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF} diff --git a/Holiday events/Holiday events.csproj b/Holiday events/Holiday events.csproj new file mode 100644 index 0000000..7b982b9 --- /dev/null +++ b/Holiday events/Holiday events.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + Holiday_events + enable + enable + + + + + + + diff --git a/Holiday events/holiday.cs b/Holiday events/holiday.cs new file mode 100644 index 0000000..cf67b84 --- /dev/null +++ b/Holiday events/holiday.cs @@ -0,0 +1,88 @@ +using Discord.WebSocket; +using Discord; +using PluginManager.Interfaces; +namespace Holiday_events +{ + public class Holiday : DBEvent + { + public string name => "Holiday Events"; + + public string description => "Happy Holiday"; + + public async void Start(DiscordSocketClient client) + { + while(true) + { + if (DateTime.Today.Hour == 0 && DateTime.Today.Minute == 0) + await VerificareData(client); + await Task.Delay(1000 * 60-1); + } + } + + private async Task VerificareData(DiscordSocketClient client) + { + string day = DateTime.Now.Day.ToString(); + string month = DateTime.Now.Month.ToString(); + + if (day == "1" && month == "1") + { + EmbedBuilder builder = new EmbedBuilder(); + builder.Title = "Happy New Year!"; + builder.Description = $"Make way for {DateTime.Now.Year}!\nNew adventures are around the corner."; + builder.ImageUrl = "https://i.imgur.com/AWhxExZ.jpg"; + builder.Color = Color.Gold; + await client.GetGuild(client.Guilds.First().Id).DefaultChannel.SendMessageAsync(embed: builder.Build()); + + } + else if (day == "1" && month == "5") + { + EmbedBuilder builder = new EmbedBuilder(); + builder.Title = "Happy May Day!"; + builder.Description = " You have worked very hard throughout the year to meet all your goals. Now it is a day to relax and rejoice.\nSending you warm wishes on International Worker’s Day."; + builder.ImageUrl = "https://i.imgur.com/SIIwelU.jpeg"; + builder.Color = Color.LightOrange; + await client.GetGuild(client.Guilds.First().Id).DefaultChannel.SendMessageAsync(embed: builder.Build()); + } + else if (day == "25" && month == "12") + { + EmbedBuilder builder = new EmbedBuilder(); + builder.Title = "Happy May Day!"; + builder.Description = "Wishing you and your family health, happiness, peace and prosperity this Christmas and in the coming New Year."; + builder.ImageUrl = "https://i.imgur.com/qsDOI4t.jpg"; + builder.Color = Color.Red; + await client.GetGuild(client.Guilds.First().Id).DefaultChannel.SendMessageAsync(embed: builder.Build()); + + } + else if (day =="1" && month == "12") + { + EmbedBuilder builder = new EmbedBuilder(); + builder.Title = "Romania National Day"; + builder.Description = "I wish the people of Romania a happy national day and peace and prosperity in the year ahead."; + builder.ImageUrl = "https://i.imgur.com/vHQnFHp.jpg"; + builder.Color = Color.Blue; + await client.GetGuild(client.Guilds.First().Id).DefaultChannel.SendMessageAsync(embed: builder.Build()); + } + + else if (day == "8" && month == "3") + { + EmbedBuilder builder = new EmbedBuilder(); + builder.Title = "National Womens Day"; + builder.Description = "Today we celebrate every woman on the planet. You bring so much love and beauty into our world just by being in it, and it makes everyone a little bit happier. The Sun shines brighter when you smile, ladies, so keep smiling! Happy Woman’s Day!"; + builder.ImageUrl = "https://i.imgur.com/dVzQ3rp.jpg"; + builder.Color = Color.Red; + await client.GetGuild(client.Guilds.First().Id).DefaultChannel.SendMessageAsync(embed: builder.Build()); + } + + else if (day == "31" && month == "10") + { + EmbedBuilder builder = new EmbedBuilder(); + builder.Title = "Happy Halloween"; + builder.Description = "This October, may your treats be many and your tricks be few. Hope you have a sweet Halloween."; + builder.ImageUrl = "https://i.imgur.com/cJf6EgI.jpg"; + builder.Color = Color.Orange; + await client.GetGuild(client.Guilds.First().Id).DefaultChannel.SendMessageAsync(embed: builder.Build()); + } + } + + } +} \ No newline at end of file diff --git a/New User/Greeting.cs b/New User/Greeting.cs new file mode 100644 index 0000000..42f5685 --- /dev/null +++ b/New User/Greeting.cs @@ -0,0 +1,27 @@ +using Discord; +using Discord.WebSocket; + +using PluginManager.Interfaces; +namespace New_User +{ + public class Greeting : DBEvent + { + public string name =>"Greeting"; + + public string description => "Greets new users"; + + public void Start(DiscordSocketClient client) + { + client.UserJoined += async (arg) => + { + IGuild? guild = client.Guilds.FirstOrDefault(); + ITextChannel chn = await guild.GetDefaultChannelAsync(); + await chn.SendMessageAsync($"A wild {arg.Username} has apperead!"); + IRole? role = guild.Roles.FirstOrDefault(x => x.Name == "New User"); + if (role == null) + await arg.Guild.CreateRoleAsync("New User", GuildPermissions.None, Color.DarkBlue); + await arg.AddRoleAsync(role); + }; + } + } +} \ No newline at end of file diff --git a/New User/New User.csproj b/New User/New User.csproj new file mode 100644 index 0000000..632bc5f --- /dev/null +++ b/New User/New User.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + New_User + enable + enable + + + + + + + diff --git a/PluginManager/Items/Command.cs b/PluginManager/Items/Command.cs index 0842f8a..057ed90 100644 --- a/PluginManager/Items/Command.cs +++ b/PluginManager/Items/Command.cs @@ -16,7 +16,7 @@ namespace PluginManager.Items /// /// The author of the command /// - public SocketUser Author; + public SocketUser? Author; /// /// The list of arguments diff --git a/StartupEvents/OnUserJoin.cs b/StartupEvents/OnUserJoin.cs index ce5bbf7..b5830cb 100644 --- a/StartupEvents/OnUserJoin.cs +++ b/StartupEvents/OnUserJoin.cs @@ -36,6 +36,7 @@ public class OnUserJoin : DBEvent client.UserJoined += async (user) => { + Console_Utilities.WriteColorText("da"); Discord.EmbedBuilder embed = new Discord.EmbedBuilder { Title = Functions.readCodeFromFile(ConfigFile, "MessageTitle", '='), @@ -46,9 +47,9 @@ public class OnUserJoin : DBEvent .AddField(Functions.readCodeFromFile(ConfigFile, "MessageField1Title", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString()), Functions.readCodeFromFile(ConfigFile, "MessageField1Text", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString())) .AddField(Functions.readCodeFromFile(ConfigFile, "MessageField2Title", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString()), Functions.readCodeFromFile(ConfigFile, "MessageField2Text", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString())) .WithFooter(Functions.readCodeFromFile(ConfigFile, "MessageFooter", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString())); - - await user.Guild.DefaultChannel.SendMessageAsync(embed: embed.Build()); - // await (await user.GetOrCreateDMChannelAsync()).SendMessageAsync(embed: embed.Build()); + Console_Utilities.WriteColorText("da"); + //await user.Guild.DefaultChannel.SendMessageAsync(embed: embed.Build()); + await (await user.CreateDMChannelAsync()).SendMessageAsync(embed: embed.Build()); };