Esempio n. 1
0
        public override void Initialize()
        {
            GuildHandler.UserJoined         += OnUserJoinedGuild;
            GuildHandler.UserLeft           += OnUserLeftGuild;
            GuildHandler.UserBanned         += OnUserBannedFromGuild;
            GuildHandler.UserUnbanned       += OnUserUnbannedFromGuild;
            GuildHandler.GuildMemberUpdated += OnGuildMemberUpdated;

            _channelId         = GetConfigCache("MessageChannelID", x => x.GetGuild().TextChannels.FirstOrDefault().ZeroIfNull());
            _onUserJoinedGuild = GetConfigCache("OnUserJoinedGuild", x => new List <string> {
                "**[USERNAME]** has joined this server!"
            });
            _onUserJoinedGuildByInvite = GetConfigCache("OnUserJoinedNewGuildByInvite", x => new List <string> {
                "**[USERNAME]** has joined this server through the help of **[INVITERNAME]**!"
            });
            _onUserLeftGuild = GetConfigCache("OnUserLeftGuild", x => new List <string> {
                "**[USERNAME]** has left this server. :C"
            });
            _onUserBannedFromGuild = GetConfigCache("OnUserBannedFromGuild", x => new List <string> {
                "**[USERNAME]** has been banned from this server."
            });
            _onUserUnbannedFromGuild = GetConfigCache("OnUserUnbannedFromGuild", x => new List <string> {
                "**[USERNAME]** has been unbanned from this server!"
            });
            _onUserNameChanged = GetConfigCache("OnUserNameChanged", x => new List <string> {
                "**[USERNAME] changed their name to **[NEWNAME]**!"
            });

            AddConfigInfoForMessage(_onUserJoinedGuild, "On New Member");
            AddConfigInfoForMessage(_onUserLeftGuild, "On Member Left");
            AddConfigInfoForMessage(_onUserBannedFromGuild, "On Member Banned");
            AddConfigInfoForMessage(_onUserUnbannedFromGuild, "On Member Unbanned");
            AddConfigInfoForMessage(_onUserNameChanged, "On Name Changed");
            AddConfigInfoForMessage(_onUserJoinedGuildByInvite, "On New Member Invited");

            // TODO: Split names and descriptions into seperate methods, and link using an identifier.
            AddConfigInfo <SocketTextChannel>("Set Message Channel", "Set channel", y => _channelId.SetValue(y.Id), (success, y) => $"Message channel set to {y.Mention}", "Channel");
            AddConfigInfo <ulong>("Set Message Channel", "Set channel", y => _channelId.SetValue(GuildHandler.GetTextChannel(y).Id), (success, y) => $"Message channel set to {GuildHandler.GetTextChannel(y).Mention}", "Channel");
            AddConfigInfo <string>("Set Message Channel", "Set channel", y => _channelId.SetValue(GuildHandler.GetTextChannel(y).Id), (success, y) => $"Message channel set to {GuildHandler.GetTextChannel(y).Mention}", "Channel");

            if (HasPermission(GuildPermission.ManageGuild))
            {
                _inviteHandler = new InviteHandler(GuildHandler);
                _ = _inviteHandler.Intialize().ConfigureAwait(false);
            }

            AddGeneralFeaturesStateAttribute("ServerMessages", "Automated messages when certain server events occur.");
        }
Esempio n. 2
0
        public override void Initialize()
        {
            GuildHandler.JoinedGuild        += OnJoinedNewGuild;
            GuildHandler.UserJoined         += OnUserJoinedGuild;
            GuildHandler.UserLeft           += OnUserLeftGuild;
            GuildHandler.UserBanned         += OnUserBannedFromGuild;
            GuildHandler.UserUnbanned       += OnUserUnbannedFromGuild;
            GuildHandler.GuildMemberUpdated += OnGuildMemberUpdated;

            _channelId        = GetConfigCache("MessageChannelID", x => x.GetGuild().TextChannels.FirstOrDefault().ZeroIfNull());
            _onJoinedNewGuild = GetConfigCache("OnJoinedNewGuild", x => new List <string> {
                "**[BOTNAME]** here, arrived ready and primed to crash at inoppertune times!"
            });
            _onUserJoinedGuild = GetConfigCache("OnUserJoinedGuild", x => new List <string> {
                "**[USERNAME]** has joined this server!"
            });
            _onUserJoinedGuildByInvite = GetConfigCache("OnUserJoinedNewGuildByInvite", x => new List <string> {
                "**[USERNAME]** has joined this server through the help of **[INVITERNAME]**!"
            });
            _onUserLeftGuild = GetConfigCache("OnUserLeftGuild", x => new List <string> {
                "**[USERNAME]** has left this server. :C"
            });
            _onUserBannedFromGuild = GetConfigCache("OnUserBannedFromGuild", x => new List <string> {
                "**[USERNAME]** has been banned from this server."
            });
            _onUserUnbannedFromGuild = GetConfigCache("OnUserUnbannedFromGuild", x => new List <string> {
                "**[USERNAME]** has been unbanned from this server!"
            });
            _onUserNameChanged = GetConfigCache("OnUserNameChanged", x => new List <string> {
                "**[USERNAME] changed their name to **[NEWNAME]**!"
            });

            AddConfigInfoForMessage(_onJoinedNewGuild, "On Bot Joined");
            AddConfigInfoForMessage(_onUserJoinedGuild, "On New Member");
            AddConfigInfoForMessage(_onUserJoinedGuildByInvite, "On New Member Inviteds");
            AddConfigInfoForMessage(_onUserLeftGuild, "On Member Left");
            AddConfigInfoForMessage(_onUserBannedFromGuild, "On Member Banned");
            AddConfigInfoForMessage(_onUserUnbannedFromGuild, "On Member Unbanned");
            AddConfigInfoForMessage(_onUserNameChanged, "On Name Changed");

            AddConfigInfo("Set Message Channel", "Set channel", new Action <int, SocketTextChannel>((x, y) => _channelId.SetValue(y.Id)), () => $"Message channel set to {GuildHandler.GetTextChannel(_channelId.GetValue ()).Name}", "Index", "Channel");
            AddConfigInfo("Set Message Channel", "Set channel", new Action <int, ulong>((x, y) => _channelId.SetValue(y)), () => $"Message channel set to {GuildHandler.GetTextChannel(_channelId.GetValue()).Name}", "Index", "Channel");
            AddConfigInfo("Set Message Channel", "Set channel", new Action <int, string>((x, y) => _channelId.SetValue(GuildHandler.FindTextChannel(y).Id)), () => $"Message channel set to {GuildHandler.GetTextChannel(_channelId.GetValue()).Name}", "Index", "Channel");

            _inviteHandler = new InviteHandler(GuildHandler);
            _ = _inviteHandler.Intialize().ConfigureAwait(false);
        }