コード例 #1
0
        public async Task UserJoined(SocketGuildUser user)
        {
            // Locate TownGuild in the database
            var guild = database.GetGuild(user.Guild);

            if (guild != null)
            {
                // TextChannel where Notifications go
                var NotificationChannel = user.Guild.GetTextChannel(guild.NotificationChannel);

                //Not the most elegant, but can't afford to spend more time on it right now
                await WelcomeModule.SendTo(user);

                // Send welcome message, parsing the welcome message string from the TownGuild property
                if (guild.WelcomeMessage != "")
                {
                    var welcome = await NotificationChannel.SendMessageAsync(guild.ParseMessage(user, discord));

                    await welcome.AddReactionAsync(new Emoji("👋"));
                }

                if (guild.MilestoneMessage != "" && (user.Guild.Users.Count % guild.MilestoneMarker) == 0)
                {
                    await NotificationChannel.SendMessageAsync($"We've now hit {user.Guild.Users.Count} members! Wooooo!");

                    await Task.Delay(1000 * 20);

                    await NotificationChannel.SendMessageAsync($"Partaayyy!");
                }
            }
        }
コード例 #2
0
 public virtual void SetUp()
 {
     _typeRegistryMock = new Mock<ITypeRegistry>();
     _welcomeControllerMock = new Mock<IWelcomeController>();
     _welcomeModule = new WelcomeModule(_typeRegistryMock.Object, () => _welcomeControllerMock.Object);
 }