Exemplo n.º 1
0
        private async Task Bot_GuildAdded(SocketGuild arg)
        {
            var cfg = await this.GuildRepo.GetConfig(arg);

            await Log.ConsoleOUT($"New Guild: {arg.Name}");


            //Log a message to the logging server.
            try
            {
                //Build embed.
                EmbedBuilder eb = new EmbedBuilder()
                                  .WithTitle("Guild Created")
                                  .WithColor(Color.Green)
                                  .AddField("Guild", arg.Name)
                                  .AddField("Members", arg.Users.Count);

                await Log.sendToChannel(LogChannel.GuildActivity, eb.Build());
            }
            catch (Exception ex)
            {
                await Log.Error(arg, ex);
            }

            //Send a welcome message to the guild.
            try
            {
                var CH = await ChannelHelper.FindChannel_For_Welcome_Message(arg);

                if (CH != null)
                {
                    //Publish a Welcome Message.

                    var eb = new Discord.EmbedBuilder()
                             .WithTitle("WarBOT")
                             .WithColor(Color.Green)
                             .WithDescription("Thanks for inviting me to your server. I will send you notifications related to Hustle Castle war events.")
                             .AddField("_ _", "_ _")
                             .AddField("For Help", $"Just type 'bot, help' or {arg.CurrentUser.Mention} help")
                             .AddField("For Support", "Either click this message or contact <@381654208073433091>.")
                             .AddField("**Setup**", "Have a server admin type: **bot, setup**")
                             .WithUrl("https://github.com/XtremeOwnage/WarBot")
                             .WithImageUrl("http://i1223.photobucket.com/albums/dd516/ericmck2000/download.jpg");

                    await CH.SendMessageAsync(embed : eb.Build());
                }
                else
                {
                    await Log.Error(arg, new Exception("Unable to send my welcome message. No permissions."));
                }
            }
            catch (Exception ex)
            {
                await Log.Error(arg, ex);
            }
        }