Exemple #1
0
        private void OnDiscordCoreReady()
        {
            if (!(DiscordCore?.Call <bool>("IsReady") ?? false))
            {
                return;
            }

            if (_pluginConfig.DiscordToServer && !string.IsNullOrEmpty(_pluginConfig.ChatChannel))
            {
                DiscordCore.Call("SubscribeChannel", _pluginConfig.ChatChannel, this, new Func <Message, object>(HandleMessage));
            }

            _bot = DiscordCore.Call <DiscordUser>("GetBot");
            if (!_storedData.BotIds.Contains(_bot.id))
            {
                _storedData.BotIds.Add(_bot.id);
                SaveData();
            }

            if (_pluginConfig.PluginSupport.AdminChat.Enabled)
            {
                DiscordCore.Call("SubscribeChannel", _pluginConfig.PluginSupport.AdminChat.ChatChannel, this, new Func <Message, object>(HandleAdminChatMessage));
            }

            _init = true;
        }
Exemple #2
0
        private void DeauthCommand(IPlayer player, string command, string[] args)
        {
            // No Permission
            if (!player.HasPermission(deauthPerm))
            {
                Message(player, "No Permission");
                return;
            }

            if (!data.Players.ContainsKey(player.Id))
            {
                Message(player, "Not Authenticated");
                return;
            }

            User.GetUser(Client, data.Players[player.Id], user => HandleRoles(user, MemberRole.Remove));
            Deauthenticate(player.Id, data.Players[player.Id]);
            Message(player, "Game-Deauthenticated");
        }
Exemple #3
0
        private void HandleRoles(User user, MemberRole memberRole)
        {
            config.Info.Roles.ForEach(roleName =>
            {
                var role = GetRoleByName(roleName);
                if (role == null)
                {
                    PrintError($"Unable to find '{roleName}'");
                    return;
                }

                switch (memberRole)
                {
                case MemberRole.Add:
                    Client.DiscordServer.AddGuildMemberRole(Client, user, role);
                    break;

                case MemberRole.Remove:
                    Client.DiscordServer.RemoveGuildMemberRole(Client, user, role);
                    break;
                }
            });
        }
Exemple #4
0
 public bool ShouldIgnoreUser(DiscordUser user)
 {
     return(_pluginConfig.IgnoreUsers.Contains(user.id));
 }